How can we prevent the issue of text and banner complications when they overlap?

My website has a banner that scrolls down with you, but whenever it hits text, the text covers the banner. How can I fix this issue and make sure the banner stays on top? https://i.sstatic.net/FsDZI.jpg here is the code snippet in question:

<!DOCTYPE html>


<html>
  <head>
    <meta charset="UTF-8">
    <meta name="description" content="this is an awesome website">
    <meta name="auther" content="ed">
    <meta name="keywords" content="html, cool, awesome">
    <meta name="viewport" content="width=device-width, initial-scale=1.0"
  </head>
  <body>
    <style>
      body { margin:0; }

      .main-title {
        color: white;
        position: absolute;
        font-size: 100px;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
      }

      .banner {
        width: 100%;
        height: 10vh;
        position:fixed;
        background-color: black;
      }

    </style>

  <div class="banner">hi</div>

  <span class="main-title"><center>name</center></span>
  <!--
  width="100%" src="img_1.png" alt="background"
  -->
  <img width="100%" src="img_1.png" alt="background"/>
  <img width="100%" src="img_1.png" alt="background"/>
  <img width="100%" src="img_1.png" alt="background"/>
  <img width="100%" src="img_1.png" alt="background"/>


  </body>
</html>

Answer №1

When both elements are positioned (absolute and fixed) without a specific z-index set, the element that appears later in the HTML markup will be displayed on top.

Approach 1: Rearrange your HTML code so that the header comes before the banner.

Approach 2: Assign a positive value to the z-index property of your banner (recommended).

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Python HTML parser with advanced CSS capabilities

Currently, I am in need of an HTML parser that is aware of CSS and functions similar to how a browser renders HTML. Specifically, I am searching for the equivalent of element.innerText in DOM-JS. For instance, let's consider the following HTML: < ...

The NgbTooltip does not activate when hovering over a <td> cell

I'm currently facing an issue with implementing ngbTooltip on <table> elements. Initially, I had trouble with <th>, but that was resolved by using the container attribute after referring to this helpful post. The main challenge arises ...

What is the correct way to align these two blocks side by side?

I have an image (https://i.stack.imgur.com/v71LR.png) and I'm trying to achieve a similar layout. Currently, my approach involves using two divs - one for the left column (containing the image) and one for the right column (with heading and paragraph ...

Problem with dropdown menu on Internet Explorer 9

Encountering a problem with a dynamic dropdown list in Internet Explorer 9. A table populates one of its columns with individual combo boxes, each created using HTML 5.0 code like this: <select id="cboABC0" class="RetrieveList cboABC" data-index="0" d ...

Trouble with updating image using url() function in JavaScript/HTML (SIMPLE FIX)

Seems pretty straightforward, but I feel like I'm overlooking something here. I am trying to swap an image defined in HTML like this: <a href="properties-single.html" class="img" id="albumPhoto1" style="background-image: url(images/work-1.jpg);"&g ...

Creating a Basic Slideshow using Javascript

I've been attempting to create a slideshow using only JavaScript, but I've run into an issue. When I set the divs to change on click, it works perfectly fine. However, when I try to set it to change at specific intervals, it doesn't work. ...

I am having difficulty with my ajax code and I am unsure of how to resolve it

Here is the code snippet. I am encountering an issue where pressing the button does not trigger any action, while I simply want to ensure that the AJAX functionality is working properly. The expected behavior is for an alert message to be displayed when th ...

Update the color of the angular material input text box to stand out

Hey there, I'm currently using Angular Material and I want to change the color of the input focus when clicked. At the moment, it's displaying in purple by default, but I'd like it to be white instead. https://i.stack.imgur.com/vXTEv.png ...

I desire a smooth fade-in transition for the background image when the addClass function is

If the background color is set to header-fixed-position, the color will fade in. However, if the background is an image, the image will not fade in. Apologies for my lack of proficiency in English. Please refer to the sample code below. Try removing the c ...

Automatically selecting and fetching checkbox values using JavaScript

I was struggling with coding a function that involved generating checkboxes using JavaScript. My goal is to automatically select the elements "March" and "September" from the array target[] and display them as checked in the text area. So, "March" and "Se ...

Is the Bootstrap navigation bar collapse button visible on larger screens?

How can I make my Bootstrap navbar collapse button work on big screens the same way it does on mobile devices? <nav class="navbar navbar-expand-md navbar-light bg-light"> <a class="navbar-brand" href="#">Default</a> <button ...

Is There a Way to Verify if JqxGrid Contains Any Errors?

Within the code below, I have successfully displayed highlighted borders when there are validation failures. Is it possible to determine any validation errors in a grid when a button is clicked? By clicking the button at the bottom, I would like to be able ...

Ways to adjust Safari printing margins using CSS to achieve borderless printing

I am struggling to eliminate margins when printing a webpage to PDF in Safari. Despite setting the page size to 'A4 borderless' in the print dialogue, Safari on OSX continues to add extra margins around my HTML. Enabling 'print backgrounds&a ...

Issue with displaying multiple checkboxes using Materialize CSS in combination with Leaflet for web-mapping overlays

I'm currently using Materialize 0.97.7 along with Leaflet 1.0.1 (the latest version). <script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.1/leaflet-src.js"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com ...

I've exhausted all options from stackoverflow with no success. Google Chrome's Autofill feature is wreaking havoc on my theme. Any suggestions on how to tackle this issue?

I designed a template with a stunning CSS layout. All I want is to have a transparent background with white font color, but Google Chrome seems to be causing issues with my theme. What steps should I take? I've exhausted all resources available onlin ...

Angular 2's Multi-select dropdown feature allows users to select multiple options

Recently, I encountered an issue with customizing CSS for angular2-multiselect-dropdown. I found the solution in this link: https://www.npmjs.com/package/angular2-multiselect-dropdown. I have included my code below. Any assistance in resolving this matter ...

Can you please save the <a href="cb289e02-ed2b-4daa-">pdf</a> with a more detailed file name?

Recently, I came across a situation where I needed to link a document accessible through a URL like http://www.myCompany.com/Documents/cb289e02-ed2b-4daa-8. In order to send this document via email to users, I used the code snippet <a href="http://www.m ...

Troubleshooting Python Markdown2 fenced-code-blocks indentation problem

Background: In my project to create a static site generator for markdown files using python, I decided to utilize the Markdown2 library to convert *.md files into HTML articles, which has been successful. To ensure code blocks are highlighted, I integrate ...

The functionality of Jquery and JS lies in working on DOM elements as opposed to

Just to start off, I want to mention that my knowledge of JavaScript and specifically jQuery is quite limited. I've encountered an issue with some JavaScript and jQuery loading on my webpage. 1) I have written some code on JSFiddle http://jsfiddle.n ...

Script for automated functions

I have implemented 4 functions to handle button clicks and div transitions. The goal is to hide certain divs and show one specific div when a button is clicked. Additionally, the background of the button should change upon hovering over it. Now, I am look ...