Expanding this question on stackoverflow.
What to modify in the CSS to make the col2
show scroll bar when the space is constrained vertically to the point it does not fit on the screen? Currently the scroll bar is displayed for the entire page.
HTML and CSS:
html,
body {
height: 100%;
margin: 0
}
.box {
display: flex;
flex-flow: column;
height: 100%;
}
.box .row.header {
flex: 0 1 auto;
}
.box .row.content {
display: flex;
flex-flow: row;
flex: 1 1 auto;
}
#col1 {
flex: 0 1 50px;
background: lightgreen;
}
#col2 {
flex: 1 1 auto;
overflow: auto;
background: lightblue;
}
.box .row.footer {
flex: 0 1 40px;
}
<div class="box">
<div class="row header">
<p><b>header</b>
<br />
<br />(sized to content)</p>
</div>
<div class="row content">
<div id="col1" class="col">col 1</div>
<div id="col2" class="col">
<p>col 2</p>
<p>col 2</p>
<p>col 2</p>
<p>col 2</p>
<p>col 2</p>
<p>col 2</p>
<p>col 2</p>
<p>col 2</p>
</div>
</div>
<div class="row footer">
<p><b>footer</b> (fixed height)</p>
</div>
</div>
This example is also here: https://jsfiddle.net/0ejLg25m/10/