JSFiddle - React, Tailwind, and code Playground
HTML
<div class="container">
<div class="box red">1 red (height 25px)</div>
<div class="box yellow flexible">2 yellow (flexible height)
START<br>...<br>...<br>...<br>...<br>...<br>...<br>
...<br>...<br>...<br>...<br>...<br>...<br>...<br>END
</div>
<div class="box green">3 green (height 50px)</div>
</div>
CSS
.container {
width: 200px;
background: #999;
border: 1px solid #000;
display: -webkit-flex;
display: flex;
-webkit-flex-direction: column;
flex-direction: column;
}
.box {
/* By default those boxes are not vertically flexible. */
-webkit-flex: none;
flex: none;
}
.box.flexible {
/* Here flex-grow is 1 so this box can be vertically reduced. */
-webkit-flex: 1 1 auto;
flex: 1 1 auto;
overflow: auto;
}
.box.red {
background: red;
height: 25px;
}
.box.yellow {
background: yellow;
height: auto; /* Same if this line is commented */
}
.box.green {
background: green;
height: 50px;
}