Marnix's answer involves using the top and bottom fill of a content item; mine involves using the upper and lower bounds.
I stumbled upon this solution myself, trying to figure out how to do something like this without resorting to tables: make the center height of the element 100%, but then set the window size model to βborder-boxβ (so that the height includes not only the content in field, but also the borders around the window), make the upper and lower borders thick (e.g. 20px), then use fixed positioning to overlay the headers and footers on the crazy, thick headers and footers of the center element.
Here is my CSS example:
html, body { height: 100%; margin: 0; padding: 0; } #content { height: 100%; -moz-box-sizing: border-box; box-sizing: border-box; border: 0; border-top: 20px solid white; border-bottom: 20px solid white; } #header, #footer { position: fixed; left: 0; right: 0; height: 20px; background-color: #eee; } #header { top: 0; } #footer { bottom: 0; }
This works on Google Chrome 24 for Mac. However, I have not tried this in other browsers.
Hope this helps someone else who is still tempted to just use the table and make the page layout already completed. :-)
Karig Jan 19 '13 at 19:22 2013-01-19 19:22
source share