views:

103

answers:

2

I have a doosie of a layout problem that looks like a browser bug.

It manifests only in FF3 (haven't tested ff2).

It only shows up on the first load of the page. If I resize the window it behaves properly.

It goes away when I put a border on the problem element, and comes back when I take the border off.

No other properties change.

Here is an image of the problem: footer width problem

Firebug's DOM inspector thinks that the footer spans the whole width in both cases. It seems like it's only the text-align:center that's not correctly respecting the full width. *Update: taking off text-align:center does not solve it. The text runs flush up against the left side of the screen (correct) or the purple box (incorrect).

The 1px purple border you can see in the screen is #centerHolder, the child of a different element and should not affect the layout of the footer, though it clearly does. *Update: Shrinking the height of the purple box to 85%, where it couldn't possibly be in the way, doesn't change the problem at all. The text still thinks the purple box is in the way.

Thanks for your comments and ideas.

HTML:

<div id="container">
    <div id="centerHolder"></div>
</div>
<p id="footer">
    Copyright ©2009 Lala Corporation
    <a class="link" onclick="ContactUs_OnClick(); return false;" href="#">Contact Us</a>
</p>

CSS:

#container{
position:relative;
height:96%;
min-height:600px;
width:100%;
min-width:975px;
max-width:1300px;
margin:0 auto;
z-index:2;
}
#centerHolder {
float:left;
margin-left:245px;
width:10%;
z-index:1000;
}
#footer {
border:1px solid green;
margin:0;
padding-top:5px;
position:relative;
text-align:center;
z-index:1;
}
+2  A: 

You need clear: both; on your #footer, it's not clearing your floated div #centerHolder

Jonny Haynes
Holy crap man, this is totally correct and I can't believe it.(can't believe it because the issue fixed itself on browser resize and the offending float is a distant cousin)But adding clear:both does, in fact, resolve the problem. Thanks.
Simple As Could Be
no problem, it's always something simple ... just staring you straight in the face! :-D
Jonny Haynes
A: 

I think there's something else going on with your page that you're not finding. Like a possible DIV tag that is not properly closed. FireFox will close tags for you if they are left open but not where you want them to. The border correcting this issue seems to be forcing the DOM to realize that the object should span wider. See the code below that I've taken directly from your example and test it. It works perfect on my install of FF 3.5.5.

Note: A quick way to locate improperly closed TAGS is to rename your HTML to an XML file extension and open it with FF. It should parse the file correctly. If not it will point to where a TAG was left open.

<html>
<head>
<style>
#container{
position:relative;
height:96%;
min-height:600px;
width:100%;
min-width:975px;
max-width:1300px;
margin:0 auto;
z-index:2;
}
#centerHolder {
float:left;
margin-left:245px;
width:10%;
z-index:1000;
}
#footer {
/*border:1px solid green;*/
margin:0;
padding-top:5px;
position:relative;
text-align:center;
z-index:1;
}

</style>
</head>


<body>
<div id="container">
    <div id="centerHolder">Here's some text</div>
</div>
<p id="footer">
    Copyright ©2009 Lala Corporation
    <a class="link" onclick="ContactUs_OnClick(); return false;" 

href="#">Contact Us</a>
</p>
</body>
</html>

Let me know if you find something. Always interested to know what you find.

Jeff