Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-02-2009, 07:45 AM   PM User | #1
pinkshiro
New Coder

 
Join Date: Mar 2005
Posts: 85
Thanks: 3
Thanked 0 Times in 0 Posts
pinkshiro is an unknown quantity at this point
Width:100%, Position:relative bug + Firefox and IE

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:

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

Code:
<!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>
pinkshiro is offline   Reply With Quote
Old 03-02-2009, 08:04 AM   PM User | #2
pinkshiro
New Coder

 
Join Date: Mar 2005
Posts: 85
Thanks: 3
Thanked 0 Times in 0 Posts
pinkshiro is an unknown quantity at this point
Actually, having a play - position:fixed; doesnt solve this problem at all
pinkshiro is offline   Reply With Quote
Old 03-02-2009, 08:18 AM   PM User | #3
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,689
Thanks: 158
Thanked 2,184 Times in 2,171 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
Do you really need width:1000px; for your #wrapper?
Removing that property would fix the width of your footer.

If you need to set a width to your wrapper, then put your footer inside that wrapper, like http://bonrouge.com/3c-hf-fluid.php?nc
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Old 03-03-2009, 01:47 AM   PM User | #4
pinkshiro
New Coder

 
Join Date: Mar 2005
Posts: 85
Thanks: 3
Thanked 0 Times in 0 Posts
pinkshiro is an unknown quantity at this point
I ended up resolving this issue by adding a min-width to the footer

Because my width was a percentage, and min-width a pixel value, it seems to work in IE6 also.

Position absolute, bottom:0 was how I used to make footers, but I found discrepancies with it and move way from it.

I would suggest it wouldn't work in this scenario as my wrapper isnt 100% width, so my footer wouldn't stretch 1005 of the browser, only 100% of the wrapper. Not what i'm after in this instance.

Ty for your thoughts.
pinkshiro is offline   Reply With Quote
Old 03-03-2009, 07:11 AM   PM User | #5
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,689
Thanks: 158
Thanked 2,184 Times in 2,171 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
Quote:
I ended up resolving this issue by adding a min-width to the footer

Because my width was a percentage, and min-width a pixel value, it seems to work in IE6 also.
IE6 completely ignores min/max-width/height, except for a special case.
See http://www.quirksmode.org/css/width.html
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Old 03-03-2009, 09:30 PM   PM User | #6
pinkshiro
New Coder

 
Join Date: Mar 2005
Posts: 85
Thanks: 3
Thanked 0 Times in 0 Posts
pinkshiro is an unknown quantity at this point
http://www.cssplay.co.uk/boxes/width.html

I used method 1 and it seemed to work...
pinkshiro is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:44 PM.


Advertisement
Log in to turn off these ads.