I still have troubles to understand how elements choose their containing block, with respect to which their relative values of e.g. height
are evaluated.
body {
margin: 0;
}
.outer {
min-height: 200px;
background: red;
overflow: hidden;
}
.inner {
height: 100%;
background: green;
}
<div class="outer">
Hello,
<div class="inner">world!</div>
</div>
Here the outer container has only a min-height set, which is apparently not enough to assert itself as containing block, even with overflow hidden.
My understanding was that without overflow hidden, there is a cyclic dependency, as the parent size depends on the child size when the child is higher than 200 px, but with overflow hidden that cyclic dependency should be gone.
What's even weirder, it starts 'working' again when I set the body to display flex.
body {
display: flex;
flex-direction: column;
height: 100vh;
margin: 0;
}
.outer {
min-height: 200px;
background: red;
overflow: hidden;
}
.inner {
height: 100%;
background: green;
}
<div class="outer">
Hello,
<div class="inner">world!</div>
</div>
What is the logic behind that?