I have been trying all sorts of methods and Googling for the last hour. Nothing I found works or did what I want. Can anyone tell me how can it be done?
Hi there, If i get it right you need a page layout made out of css (divs) which always fits, streches 100% to the browser size. I don't think you can make it by CSS only or fix me! I have gave it a try, and with some fancy javascript, which i wrote, i found it possible to make this work. I've tested it in Firefox 2, Explorer 6 and Opera 9.24. Works fine.
Here is the code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <title>DIV layout test</title>
<script type="text/javascript"> function getWindowInnerH(){ var innerH = null; if (typeof(window.innerHeight) == "number"){//MOZILLA, OPERA innerH = window.innerHeight; }else if (typeof(document.documentElement.clientHeight) == "number"){//IE 6+ innerH = document.documentElement.clientHeight; }
return innerH; }
function arrange(){ var headerE = document.getElementById("header"); var middleE = document.getElementById("middle"); var footerE = document.getElementById("footer");
if (!headerE || !middleE || !footerE){ return; }
//get window's inner height var innerH = getWindowInnerH();
//get header's and footer's height var headerH = headerE.offsetHeight; var footerH = footerE.offsetHeight; //calc middle's heigth var middleH = Math.round(innerH - (headerH + footerH));
I need something similar. I have a simple three row design. The top row height (header) needs to be fluid. The middle row height needs to be a fixed height and the bottom row height (footer) needs to be fluid as well as stuck to the bottom of the page. This was easy using tables, however, I would prefer the design to be done with CSS.