Here is the first example. This works fine. Here .b occupies 50% of the height of .a.
.a {
background: orange;
height: 200px;
padding: 10px;
}
.b {
background: lightblue;
border: 5px solid blue;
height: 50%;
}
<div class="a">
<div class="b">
</div>
</div>
Here is the second example. It is pretty much the same except that min-height is used to set the height of .a instead of using height.
.a {
background: orange;
min-height: 200px;
padding: 10px;
}
.b {
background: lightblue;
border: 5px solid blue;
height: 50%;
}
<div class="a">
<div class="b">
</div>
</div>
But in this second example, the blue box almost vanishes. It is not 50% the height of .a anymore. Why does this issue happen? How to fix it while using min-height for .a?