Please let me add my 5 cents here and offer a classical solution:
html {height:100%;}_x000D_
body {height:100%; margin:0;}_x000D_
#idOuter {position:relative; width:100%; height:100%;}_x000D_
#idHeader {position:absolute; left:0; right:0; border:solid 3px red;}_x000D_
#idContent {position:absolute; overflow-y:scroll; left:0; right:0; border:solid 3px green;}
_x000D_
<div id="idOuter">_x000D_
<div id="idHeader" style="height:30px; top:0;">Header section</div>_x000D_
<div id="idContent" style="top:36px; bottom:0;">Content section</div>_x000D_
</div>
_x000D_
This will work in all browsers, no script, no flex. Open snippet in full page mode and resize browser: desired proportions are preserved even in fullscreen mode.
idHeader.height
and idContent.top
are adjusted to include border,
and should have the same value if border is not used. Otherwise
elements will pull out of the viewport, since calculated width does
not include border, margin and/or padding.left:0; right:0;
can be replaced by width:100%
for the same
reason, if no border used.padding-top
and/or
padding-bottom
attributes to #idOuter
element.To complete my answer, here is the footer layout:
html {height:100%;}_x000D_
body {height:100%; margin:0;}_x000D_
#idOuter {position:relative; width:100%; height:100%;}_x000D_
#idContent {position:absolute; overflow-y:scroll; left:0; right:0; border:solid 3px green;}_x000D_
#idFooter {position:absolute; left:0; right:0; border:solid 3px blue;}
_x000D_
<div id="idOuter">_x000D_
<div id="idContent" style="bottom:36px; top:0;">Content section</div>_x000D_
<div id="idFooter" style="height:30px; bottom:0;">Footer section</div>_x000D_
</div>
_x000D_
And here is the layout with both header and footer:
html {height:100%;}_x000D_
body {height:100%; margin:0;}_x000D_
#idOuter {position:relative; width:100%; height:100%;}_x000D_
#idHeader {position:absolute; left:0; right:0; border:solid 3px red;}_x000D_
#idContent {position:absolute; overflow-y:scroll; left:0; right:0; border:solid 3px green;}_x000D_
#idFooter {position:absolute; left:0; right:0; border:solid 3px blue;}
_x000D_
<div id="idOuter">_x000D_
<div id="idHeader" style="height:30px; top:0;">Header section</div>_x000D_
<div id="idContent" style="top:36px; bottom:36px;">Content section</div>_x000D_
<div id="idFooter" style="height:30px; bottom:0;">Footer section</div>_x000D_
</div>
_x000D_