I am experiencing an issue with the z-indexes of two div
s: one with default positioning and the other with a fixed position.
No matter how I adjust the z-index values, it appears impossible to make the fixed-positioned element go behind the statically positioned element.
#over {
width: 600px;
z-index: 10;
}
#under {
position: fixed;
top: 5px;
width: 420px;
left: 20px;
border: 1px solid;
height: 10%;
background: #fff;
z-index: 1;
}
<div id="over">
Hello Hello HelloHelloHelloHelloHello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello
</div>
<div id="under"></div>
You can view this on jsfiddle here: http://jsfiddle.net/mhFxf/
To work around this issue, I have used position:absolute
on the static element. However, I am curious to understand why this behavior is occurring.
(While there is a similar question on stackoverflow (Fixed Positioning breaking z-index), I have not found a satisfactory answer, which is why I am posting my query here along with example code)