Hi, I'm really trying to work with div's and I can't seem to get the equivalent to the following simple table layout:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Table example</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type="text/css">
html, body {height: 100%}
.content {width: 750px; vertical-align: top}
</style>
</head>
<body style="margin: 0; padding: 0">
<table style="height: 100%; width: 100%; border-collapse: collapse">
<tr style="background-color: #666666">
<td></td>
<td class="content" style="height: 100px"><h1>Header Content</h1></td>
<td></td>
</tr>
<tr style="background-color: #BBBBBB">
<td></td>
<td class="content" style="background-color: #FFFFFF"><h1>Main Content</h1></td>
<td></td>
</tr>
<tr style="background-color: #666666">
<td></td>
<td class="content" style="height: 100px"><h1>Footer Content</h1>
</td>
<td></td>
</tr>
</table>
</body>
</html>
The important elements that I want to preserve:
1.) Any real content is fixed width. (in this case, 750px)
2.) The header and footer backgrounds expand to 100% of the page width.
3.) The main content background does not expand horizontally, but does expand vertically to fill the area between header and footer.
4.) The footer is always at the bottom of the page even when the main content is not very tall.
I've tried a number of strategies and found at least 2 different ways to keep the footer at the bottom of the page using divs. Unfortunately, if the main content is in a div, there's doesn't seem to be any way to make it expand vertically to fill the space between the header and footer on short pages.
Edit: Changed the example to show that it works even when not in quirks mode. The above validates.
Edit 2:
I've found a way to do this for the most part with javascript. So, I guess my question is: how do I do this without javascript. Here's what I'm using (which I'm sure only works in firefox, but I could fix that up):
<script type="text/javascript">
function changeDiv() {
document.getElementById("content").style.minHeight = document.body.clientHeight - 200 + "px";
}
changeDiv();
window.onresize = changeDiv;
</script>
"content" would specify the main content div I want to expand.