Forum Moderators: not2easy
html, body {
height:100%;
margin:0;
padding:0
}
#wrapper { min-height:100% }
* html #wrapper { height:100% }/* for ie6 which treats height as min-height anyway */
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<style>
html, body {
height:100%;
margin:0;
padding:0
}
#wrapper {
min-height:100%;
border:2px solid red;
background:#ccc;
border-top:none;
margin-top:-2px;
}
* html #wrapper { height:100% }/* for ie6 which treats height as min-height anyway */
#header { border-top:4px solid red; }
</style>
</head>
<body>
<div id="wrapper">
<div id="header"></div>
</div>
</body>
</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>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Sticky Footer at Bottom</title>
<style type="text/css">
html, body {
height:100%;/* needed to base 100% height on something known*/
text-align:center;
margin:0;/* must clear defaults or 100% will be too large */
padding:0;/* "" */
}
h1, h2, p {
padding:0 10px;
margin:0 0 1em
}
#outer {
width:760px;
background:#ffc;
margin:auto;
min-height:100%;
margin-top:-300px;/*footer height - this drags the outer 300px up through the top of the monitor */
text-align:left;
clear:both;
}
* html #outer { height:100% }/* for ie6 as it doesn't understand min-height but treats height as a minimum */
#header {
background:red;
border-top:300px solid #fff; /* soak up negative margin and allows header to start at top of page and not above it*/
}
#footer {/* footer now sits at bottom of window*/
background:red;
width:760px;
margin:auto;
height:300px;/* must match negative margin of #outer and must be a fixed height*/
clear:both;
}
/*Opera Fix*/
body:before {/* cures the sticky bug in opera where the footer doesn't re-position after window resize*/
content:"";
height:100%;
float:left;
width:0;
margin-top:-32767px;/* - negate effect of float*/
}
#outer:after {/*overflow hidden would kill opera so we use this method of float clearing*/
clear:both;
display:block;
height:1%;
content:" ";
}
</style>
</head>
<body>
<div id="outer">
<div id="header">
<h1>Sticky Footer</h1>
</div>
<p>test</p>
<p>test</p>
<p>test</p>
</div>
<div id="footer">
<p>Footer</p>
</div>
</body>
</html>