I had this situation in CSS which I never saw before, where an element sits between the background and the text of another element. I know that what is happening here is not best practice (element is larger than its given height), but to further my CSS knowledge, I'd be interested in understanding what is exactly going on (in terms of stacking context, etc.):
.search {
width: 2rem;
height: 10rem;
background: red;
margin-left: 2rem;
}
.header__top {
display: flex;
height: 2rem;
background: blue;
}
.header__bottom {
font-size: 2rem;
background: green;
}
<div class="header__top"><div class="search"></div></div>
<div class="header__bottom">Hello!</div>
Theoretically, anything related to stacking without a given z-index (as is the case here) should be described in stacking without the z-index property but I can't find the situation being mentioned there.
EDIT
I don't know if this is weird, but I post questions like this not to get a solution (there are many in this case), but because I want to understand the theory of CSS better. My goal is to see some CSS code and know how it will be rendered. Whenever something happens which I cannot explain using what I learned so far (stacking context, box model, etc.) and I can't find some documentation explaining the theory behind the phenomena, I post it somewhere.