I have a problem with z-index
property. I have some absoluted positioned elements (div
in the code)one inside each other. The first div
inside (red div) naturally would be in front of its parent (aliceblue element), thus I give a negative z-index to the red div inside and it's ok. But the aqua div (inside the red div) is in front of red element too (instead I would lay out the aqua element behind the red element), to lay out it behind I give it z-index:-5
for example but it doesn't work because I created a new stacking context different from stacking context of its father
div {
width: 300px;
height: 300px;
text-align: center;
position: absolute;
}
.a {
background-color: aliceblue;
position: relative;
}
.a1 {
background-color: red;
left: 20px;
top: 20px;
z-index: -1;
}
.a11 {
background-color: aqua;
left: 10px;
top: 10px;
/* z-index: -5; This doesn't work*/
}
.a2 {
background-color: yellow;
top: 40px;
z-index: -2;
}
<div class="a">
A
<div class="a1">
A1
<div class="a11">A11</div>
</div>
<div class="a2">A2</div>
</div>