My web app features both upper and lower elements (div
) with a position: fixed
. Each element has child popups also with position: fixed
.
Even though I want to position the popup above its parent element, using z-index
doesn't work due to inheritance from the parents.
I've searched on Stack Overflow for a solution to this issue but haven't found one that addresses it directly.
You can view the HTML/CSS code at: https://jsfiddle.net/pLsdspon/
<html>
<head></head>
<body style="height: 100%;">
<div style="
background-color: red;
position: fixed;
display: block;
width: 100%;
height: 50%;
top: 0%;
z-index: 2; ">
Top
<div style="
background-color: pink;
position: fixed;
display: block;
width: 80px;
height: 200px;
top: 40%;
left: 100px;
z-index: 20; ">
PopUp-Top - Need to be on top!
</div>
</div>
<div style="
background-color: green;
position: fixed;
display: block;
width: 100%;
height: 50%;
top: 50%;
z-index: 2; ">
Bottom
<div style="
background-color: lightgreen;
position: fixed;
display: block;
width: 80px;
height: 200px;
top: 40%;
left: 200px;
z-index: 20; ">
PopUp-Bottom - Need to be on top!
</div>
</div>
</body>
</html>