As far as I know, this can only be done using Flexbox.
Fiddle
(Relevant) CSS
#wrapper{ padding: 10px; vertical-align: middle; background-color: cyan; min-height: 100px; max-height: 300px; -ms-box-orient: vertical; display: -ms-flex; height: 100%; display: -webkit-box; display: -moz-flex; display: -ms-flexbox; display: -webkit-flex; display: flex; -ms-flex-direction: column; -webkit-flex-direction: column; flex-direction: column; -moz-box-sizing: border-box; box-sizing: border-box; } #content { -ms-flex: 1 1 auto; -webkit-flex: 1 1 auto; flex: 1 1 auto; overflow: auto; height:0; min-height: 0; }
A few points:
0) ( EDIT:) . In order to get scrolling only over the (green) content, I had to slightly change the layout to put the yellow area in the title.
1) I only apply flex-grow: 1 (i.e. flex: 1 1 auto) to scrollable content; other elements may have a fixed or dynamic height.
2) There is a hack (?), Which I saw here , that placing the height: 0 on the elements of the container causes the bar to scroll vertically. (Here I used both height and minimum height, because this hack only worked in firefox with a minimum height)
3) For this to work in Firefox <22 - you need to enable the flexbox execution flag like this
4) Flexbox support is surprisingly good in modern browsers (see here ), but you need to add some CSS code for the browser to work (see the script above)
source share