What a pain footers are…. This took some figuring out, but here is a working model. Tested in IE6, IE8, FF3, Safari4, Chrome, Opera & Safari on the iPhone. Should copy and paste over fine.
HTML
<!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"> <head> <title>title</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link href="css/sheet.css" rel="stylesheet" type="text/css" /> <!--[if IE]> <link href="css/ie.css" rel="stylesheet" type="text/css" /> <![endif]--> </head> <body> <div id="header"> header content</div> <div id="outer"> <div id="clearheader"> </div> <div id="left">side bar content</div> <div id="middle"><div id="content">Main page content</div></div> <div id="clearfooter"></div> </div> <div id="footer">footer content</div> </body> </html>
CSS
@charset "UTF-8";
/* CSS Document */
* {
margin:0;
padding:0;
border:none;
z-index:0;
}
html, body {
height:100%;
background-image:url(../images/bgtile.jpg);
}
body {
font-family:arial, sans-serif;
color:#000;
font-size:82%;
background:transparent;
}
#header{
position:absolute;
top:0;
left:0;
width:100%;
height:178px;
line-height:100px;
background:transparent;
color: #FFF;
font-weight:bold;
text-align:left;}
#clearheader {
height:178px;
}
#outer{
min-height:100%;
margin-left:200px;
margin-right:100px;
margin-bottom:-100px;
background:transparent;
}
#left {
position:relative;
width:200px;
text-align:center;
float:left;
z-index:100;
margin-left:-199px;
left:-1px;
background-color:#FFF;
margin-top:10px;
}
#middle {
width:90%;
float:left;
position:relative;
z-index:1;
margin:0 -1px;
padding-left:10%;
padding-right:5%x;
padding-bottom:50px;
padding-top:10px;
}
#content {
background-color:#FFF;
padding-left:10%;
padding-right:5%;
padding-bottom:50px;
padding-top:10px;
}
p {
padding:15px 15px 0 15px;
}
#clearfooter {
clear:both;
height:115px;
}
#footer {
width:100%;
clear:both;
height:100px;
line-height:100px;
background-color:#FFF;
color: #000;
font-weight:bold;
text-align:center;
position:relative;
}
IE Conditional CSS
#outer {
height:100%;
}
#left {margin-right:-3px;
}
Notes about the layout: Notice the header heights – in this example they are 178px high. Also note the footer heights – in this example the footer is 100px high. In order to change the height of the footer for example; you need to adjust the height of the #clearfooter div, and the #footer div. Same with the header, it’s clearing element, and their associated paddings & margins. This could be much simpler, but since this example required a tiling background image and some space between the main content and the side bar it needed a few extra things.
Did you appreciate this article? Please click here to donate.