I'm trying to have a vertical scrollable div in the remaining space of some elements. None of them have a fixed height.
All I got is a flexbox element that adjusts to its content, but what I really need is that the element fill up the empty space and it's content just scroll there.
HTML
<div class="wrapper-1">
<div>some stuff</div>
<div>some other stuff</div>
</div>
<div class="wrapper-2">
<div>more and more and more and more and more and more and more and more and more and more and more and more and more and more and more and more and more and more and more and more and more and more and more and more and more and more and more and more and more and more and more and more and more and more and more and more and more and more and more and more and more and more and more and more more and more and more and more and more and more and more and more and more and more and more and more and more and more and more and more and more and more and more and more stuff</div>
</div>
<div class="wrapper-3">
<div id="header">
<div>My</div>
<div>Header than can grow</div>
</div>
<div id="content">
<div>My Content that will fill remaining space untill page has to scroll</div>
<div>My Content that will fill remaining space untill page has to scroll</div>
<div>My Content that will fill remaining space untill page has to scroll</div>
<div>My Content that will fill remaining space untill page has to scroll</div>
<div>My Content that will fill remaining space untill page has to scroll</div>
<div>My Content that will fill remaining space untill page has to scroll</div>
<div>My Content that will fill remaining space untill page has to scroll</div>
<div>My Content that will fill remaining space untill page has to scroll</div>
<div>My Content that will fill remaining space untill page has to scroll</div>
<div>My Content that will fill remaining space untill page has to scroll</div>
<div>My Content that will fill remaining space untill page has to scroll</div>
</div>
</div>
CSS
html, body {
margin: 0;
height: 100%;
}
.wrapper-1 {
background: white;
}
.wrapper-2 {
background: lime;
}
.wrapper-3 {
display: flex;
flex-direction: column;
}
#header {
background: #edc;
flex: 1 1 40px;
}
#content {
flex: 1 1 auto;
background: yellow;
overflow: auto;
}
#content div {
min-height: 50px;
}
The #content should have the height from the #header to the bottom of the page.
The perfect solution would be using only CSS but an alternative JS solution could help, the thing is that this have to work even when resizing the browser window.