I am very enthousiastic about container queries. Finally, this CSS featured had landed in all browsers. But, when I create multiple subsequent containers, and I put a absolutely positioned z-indexed element in one, a following container covers this element.
My case: z-indexed-menu covered
- menu (position: absolute, z-index: 9) is part of the dark blue box that has
container-type: inline-size
- but covered by the lightblue box that is also
container-type: inline-size
Isolated case study:
.block {
display: inline-block;
background-color: darkblue;
color: lightblue;
margin: 2px;
width: 100%;
}
.block.container {
container-type: inline-size;
}
.popout {
background-color: darkgreen;
color: lightgreen;
position: absolute;
z-index: 9;
}
hr {
margin-bottom: 4rem;
}
<div class="block">
<p>Some content in regular inline-block</p>
<div class="popout">
<p>Popping out of it.</p>
<p>Popping out of it.</p>
<p>Popping out of it.</p>
</div>
</div>
<div class="block">
<p>Some content in regular inline-block</p>
</div>
<hr />
<div class="block container">
<p>Some content in block with
<pre>container-type: inline-size;</pre>
</p>
<div class="popout">
<p>Popping out of it.</p>
<p>Popping out of it.</p>
<p>Popping out of it.</p>
</div>
</div>
<div class="block container">
<p>Some content in block with
<pre>container-type: inline-size;</pre>
</p>
</div>
https://codepen.io/gofix/pen/yLREXaN
How can I apply container-type without introducing a new absolut-ish layout context.
I tried giving all those container-type: inline-size
a low z-index, and that 'kinda' works, but I don't want to fill my entire page with z-indexes.