If you want your elements to be fixed, you should use CSS positioning. Your current solution is already close, but it is a bit complicated.
Suppose you want to have three blocks:
HEADER CONTENT FOOTER
the most natural way is to place them in a container (not required if your site consists of only these 3 elements) and positions them as absolute. The top of HEADER is 0, for the bottom of FOOTER it is 0. In CONTENT, you must adjust the top and bottom to make sure that this is the height of your footer / header.
So, if you use #wrapper, #header, #content and #footer, this is the code you need:
#wrapper{position:absolute; top:0;bottom:0;width:100%;} #header, #footer, #content{position:absolute; width:100%;} #header{top:0; background-color:#faa;height:50px;} #content{top:50px;bottom:150px; overflow:auto;} #footer{bottom:0px; background-color:#afa; height:150px}
Demo
EDIT : Your updated demo . Do not specify a height value if you want to use fixed positioning. Instead of implicit height, use top and bottom . Also use overflow:auto for scrollbars. I made the following changes:
#mid { background: #222; bottom:50px; overflow:auto; width: 100%; position: fixed; top: 100px; }
source share