I want my c1 to be fully stretched, but I wonder why when I apply flex:1 it doesn’t fill up the space.
.wrap {
display:flex;
flex-direction: column;
}
.c1 {
background: red;
flex: 1;
}
.c2 {
background: blue;
}
<div class='wrap'>
<div class='c1'>
<div>child 1</div>
<div>more content</div>
</div>
<div class='c2'>child 2</div>
</div>
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
In your wrap class you have to add the height.
.wrap {
display:flex;
flex-direction: column;
height: 100vh;
}
.c1 {
background: red;
flex: 1;
}
.c2 {
background: blue;
}
<div class='wrap'>
<div class='c1'>
<div>child 1</div>
<div>more content</div>
</div>
<div class='c2'>child 2</div>
</div>
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0