You could simply set the container to flexbox.
#cont {
padding: 5px;
background-color: red;
max-height: 150px;
max-width: 50%;
display: flex; /*added*/
flex-direction: column; /*added*/
}
jsFiddle
#cont {
padding: 5px;
background-color: red;
max-height: 150px;
max-width: 50%;
display: flex; /*added*/
flex-direction: column; /*added*/
}
#body {
background-color: blue;
overflow-y: auto;
overflow-x: hidden;
flex: 1; /* added */
}
#head {
background-color: green;
}
<div id='cont'>
<div id='head'>
<div>Head</div>
</div>
<div id='body'>
<div>Body</div>
<div>Body</div>
<div>Body</div>
<div>Body</div>
<div>Body</div>
<div>Body</div>
<div>Body</div>
<div>Body</div>
<div>Body</div>
<div>Body</div>
<div>Body</div>
<div>Body</div>
</div>
</div>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…