When you give min-height to parent and percentage height to the child, the child doesn't get any height.
.p {
min-height: 50vh;
background-color:beige;
}
.c {
height: 50%;
background-color: red;
}
<div class="p">
<div class="c"> hi </div>
</div>
But if you give explicit height to parent, even if it is smaller than min-height, the child gets a height, but it is relative to min-height and not height provided( when height < min-height)
.p {
min-height: 50vh;
height: 1px;
background-color:beige;
}
.c {
height: 50%;
background-color: red;
}
<div class="p">
<div class="c"> hi </div>
</div>
- First, I want to understand this behaviour
- How can I give the height in percentage to the child with min-height only on the parent