z-index not working with fixed positioning

Add position: relative; to #over

    #over {
      width: 600px;
      z-index: 10;
      position: relative;    
    }
    
    #under {
      position: fixed;
      top: 5px;
      width: 420px;
      left: 20px;
      border: 1px solid;
      height: 10%;
      background: #f0f;
      z-index: 1;
    }
    <!DOCTYPE html>
    <html>
    <body>
        <div id="over">
            Hello Hello HelloHelloHelloHelloHello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello
        </div>  
    
        <div id="under"></div>
    </body>
    </html>

Fiddle

Leave a Comment