pinkshiro
03-02-2009, 07:45 AM
I've just come across a bit of a bug in some code i've been reusing for quite a while - whoops.
I'm trying to make my footer div 100% width of the browser.
I have a wrapper with a width of 1000px, and a 100% height.
My footer div is positioned relatively, underneath the wrapper, and is given a negative margin to pop back up over the top of the wrapper div.
When my browser is shrunk down to less than 1000 pixels, the footer div doesn't stretch 100% of the browser...only 100% of the viewport! In all browsers! I don't understand this.
Replacing position:relative with position:fixed on my footer corrects the problem. I just dont like not knowing why. Can anyone shed some light? Here's my code:
html, body{
width:100%;
height:100%;
margin:0px;
padding:0px;
}
div#wrapper{
z-index:1;
width:1000px;
height:100%;
min-height:100%;
background-color:#6666FF;
}
html>body #wrapper {
height: auto;
}
div.footer{
width:100%;
height:40px;
margin-top:-40px;
background-color:#33FF99;
position:relative;
z-index:10;
}
and my 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=utf-8" />
<link href="styles1.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="wrapper">
</div>
<div class="footer">
</div>
</body>
</html>
I'm trying to make my footer div 100% width of the browser.
I have a wrapper with a width of 1000px, and a 100% height.
My footer div is positioned relatively, underneath the wrapper, and is given a negative margin to pop back up over the top of the wrapper div.
When my browser is shrunk down to less than 1000 pixels, the footer div doesn't stretch 100% of the browser...only 100% of the viewport! In all browsers! I don't understand this.
Replacing position:relative with position:fixed on my footer corrects the problem. I just dont like not knowing why. Can anyone shed some light? Here's my code:
html, body{
width:100%;
height:100%;
margin:0px;
padding:0px;
}
div#wrapper{
z-index:1;
width:1000px;
height:100%;
min-height:100%;
background-color:#6666FF;
}
html>body #wrapper {
height: auto;
}
div.footer{
width:100%;
height:40px;
margin-top:-40px;
background-color:#33FF99;
position:relative;
z-index:10;
}
and my 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=utf-8" />
<link href="styles1.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="wrapper">
</div>
<div class="footer">
</div>
</body>
</html>