I'm trying to fill the vertical space of a flex item inside a Flexbox.
.container {
height: 200px;
width: 500px;
display: flex;
flex-direction: row;
}
.flex-1 {
width: 100px;
background-color: blue;
}
.flex-2 {
position: relative;
flex: 1;
background-color: red;
}
.flex-2-child {
height: 100%;
width: 100%;
background-color: green;
}
<div class="container">
<div class="flex-1"></div>
<div class="flex-2">
<div class="flex-2-child"></div>
</div>
</div>
And here's the JSFiddle
flex-2-child
doesn't fill the required height except in the two cases where:
flex-2
has a height of 100% (which is weird because a flex item has a 100% by default + it is buggy in Chrome)flex-2-child
has a position absolute which is also inconvenient
This doesn't work in Chrome or Firefox currently.
height:100%
but they are rendering with natural height instead. And the weird thing is if I change their height toauto
, then they render asheight:100%
like I was trying to do. It is definitely not intuitive if that's how it should work. – trusktr