If css3 is an option, you could use FLEXBOX
FIDDLE1 and FIDDLE2
The Flexbox Layout (Flexible Box) module (currently a W3C Candidate
Recommandation) aims at providing a more efficient way to lay out,
align and distribute space among items in a container, even when their
size is unknown and/or dynamic (thus the word "flex"). -- from css-tricks
Markup:
<div class="container">
<header>The header text can change so the height can't be fixed.
Should never have a scrollbar
</header>
<div class="content">
Lorem ipsums in futurum.
</div>
<footer>
The footer's height is fixed
</footer>
</div>
(Relevant) CSS:
.content
{
-webkit-flex: 1 1 auto;
flex: 1 1 auto;
overflow: auto;
height:0; /* triggers scroll */
min-height: 0; /* triggers scroll */
}
A few points to mention:
1) I only apply flex-grow:1 (ie flex: 1 1 auto) to the scrollable content; the other items can have a fixed or dynamic height.
2) There's a hack(?) that I saw here, that placing height:0 on the container elements triggers a vertical scroll bar. (Here I used both height and min-height because this hack only worked in firefox with min-height)
3) For this to work in Firefox < 22 - you need to enable the flexbox runtime flag like this
4) Support for flexbox is surprisingly good in modern browsers (see here) but you need to add some browser specific css to get this working (see the above fiddle)