Solution 1 :

Both elements are positioned (absolute and fixed), and don’t have z-index set. In this case, the element that is defined later in the markup will be displayed on top.

Solution 1: Move the header above the banner in your HTML.

Solution 2: Give your banner positive z-index (preferable).

Problem :

I have a banner at the top of my website that follows you down the page, but when it encounters text, the text goes on top of the banner. How can I make the banner go on top?
picture of my website
this is my code:

<!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>

Comments

Comment posted by wondercoll

Thanks!! this really helped!!

By