To better see the issue run below html code on firefox and on chrome and see the difference.
The code works on all browsers but not Chrome. The issue is when you set display to flex
and flex-direction
to column
, and set one of the flex items flex-grow
to 1. The content of this flex item can't have have height set to 100%.
Can you help me with work around without using JavaScript, or css Calc function? Because in the actual project things are much more complex than this.
h1 {
margin: 0;
padding: 0;
color: white;
}
div {
font-size: 38px;
color: white;
}
<body style="margin: 0; padding: 0;">
<div style="height: 100vh; background: royalblue;">
<div style="display: flex; flex-direction: column; height: 100%;">
<div style="background: rosybrown; flex-grow: 0;">
This is first flex item
</div>
<div style="flex-grow: 1; background-color: red;">
<div style="background-color: orange; height: 100%;">
This div is inside flex item that grows to fill the remaining space. and has css height 100% but its not filling its parent.
<br/>this div need to be filling its parent (the red div). this works on all other browsers.
</div>
</div>
</div>
</div>
</body>