I have flexbox( flex-direction: row) with 2 columns of content and a fixed height. I want the left and right columns to have a red and blue background respectively. If column overflows, a scrollbar appears flexbox(the overflowed part is still red / blue). If the height of the column contents is less than the height flexbox, the space below should be red / blue.
Without using gradient colors or javascript, how can I achieve this effect?
Demo (I want the gray part to be blue):
#c1 {
background-color: gray;
display: flex;
height: 200px;
overflow-y: auto;
align-items: baseline;
}
#left {
flex: 1;
background-color: red;
}
#right {
flex: 1;
background-color: blue;
}
<div id="c1">
<div id="left">
<div>line</div>
<div>line</div>
<div>line</div>
<div>line</div>
<div>line</div>
<div>line</div>
<div>line</div>
<div>line</div>
<div>line</div>
<div>line</div>
<div>line</div>
<div>line</div>
<div>line</div>
<div>line</div>
</div>
<div id="right">
<div>line</div>
</div>
</div>
Run codeHide result
EDIT
Methods that do not work:
- Setting
align-items: stretch: the crowded part will be gray. position: absolute div, flexbox : div , .