/    Sign up×
Community /Pin to ProfileBookmark

Problems w/ float:left in NS/Win

I am trying to float 4 DIVs across my footer, and the 4th floated DIV is falling under the 1st floated DIV in NS 8.1 (Display like IE) and is floating properly in NS 7.1, but there a margin at the bottom, that is equal to the height of the 4th DIV.

Everything displays properly in Win/Pro: FF 1.5, IE 7, IE 6, IE 5.5 and Opera 9.

I have stripped away all the excess code to make it easier to see the problem. Please take a look at my CSS + XHTML below. I appreciate any and all suggestions!

[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>
<title>TEST</title>
<meta http-equiv=”Content-Type” content=”text/html;charset=utf-8″ />

<style type=”text/css”>
* {margin: 0; padding: 0;}
body {font-family: Verdana, Arial, sans-serif;
font-size: 0.8em;
font-style: normal;
font-weight: normal;
line-height: 150%;}
#container {width: 770px; overflow: hidden;}

#footer {width: 770px;}

#footerSiteLinks {padding: 0 0 0 10px; width: 760px; min-height: 1px; height: auto; border-bottom: 1px solid #CDCDCD; overflow: auto;}
* html #footerSiteLinks {width: 770px; width: 760px;}
.footerSiteLinkBlock {padding: 6px; width: 178px; font-size: 0.75em; float: left;}
* html .footerSiteLinkBlock {width: 190px; width: 178px;}
.footerSiteLinkBlock h2 {font-size: 1em;}

/**/
* html #footerSiteLinks {height: 1px; overflow: visible;}
/**/

</style>

</head>

<body>
<div id=”container”>

<div id=’footer’>
<div id=’footerSiteLinks’ style=’background:#FFAA00;’>
<div class=’footerSiteLinkBlock’ style=’background:#FF0000;’>
<h2>SIX</h2>
<p>SIX</p>
<p>SIX</p>
<p>SIX</p>
<p>SIX</p>
<p>SIX</p>
</div>
<div class=’footerSiteLinkBlock’ style=’background:#FFFF00;’>
<h2>FOUR</h2>
<p>FOUR</p>
<p>FOUR</p>
<p>FOUR</p>
</div>
<div class=’footerSiteLinkBlock’ style=’background:#FF0000;’>
<h2>EIGHT</h2>
<p>EIGHT</p>
<p>EIGHT</p>
<p>EIGHT</p>
<p>EIGHT</p>
<p>EIGHT</p>
<p>EIGHT</p>
<p>EIGHT</p>
</div>
<div class=’footerSiteLinkBlock’ style=’background:#00FFFF;’>
<p>ONE</p>
</div>
</div>
</div>

</div>
</body>
</html>
[/code]

to post a comment
CSS

3 Comments(s)

Copy linkTweet thisAlerts:
@m9dauthorMar 12.2007 — I have reworked the original code and now float LIs in a UL rather than using DIVs. I also have removed the overflow:hidden value from the #container and added float:left values to all the parent elements above the floated LIs.

I have tested this in WinXP/ FF 1.5, NS 8.1, NS 7.1, IE 7, IE 6, IE 5.5 and Opera 9. Here is my code, please let me know if I am missing something.

<i>
</i>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
&lt;title&gt;TEST&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html;charset=utf-8" /&gt;

&lt;style type="text/css"&gt;
* {margin: 0; padding: 0;}
body {font-family: Verdana, Arial, sans-serif;
font-size: 0.8em;
font-style: normal;
font-weight: normal;
line-height: 150%;}
#container {width: 770px; float: left;}

#footer {width: 770px; float: left;}

ul#footerSiteLinks {display: block; padding: 0 0 0 10px; width: 760px; border-bottom: 1px solid #CDCDCD; list-style: none; float: left;}
* html ul#footerSiteLinks {width: 770px; width: 760px;}
li.footerSiteLinkBlock {padding: 6px; width: 178px; font-size: 0.75em; float: left;}
* html li.footerSiteLinkBlock {width: 190px; width: 178px;}
li.footerSiteLinkBlock h2 {font-size: 1em;}
&lt;/style&gt;

&lt;/head&gt;

&lt;body&gt;
&lt;div id="container"&gt;

&lt;div id='footer'&gt;
&lt;ul id='footerSiteLinks' style='background:#FFAA00;'&gt;
&lt;li class='footerSiteLinkBlock' style='background:#FF0000;'&gt;
&lt;h2&gt;SIX&lt;/h2&gt;
&lt;p&gt;SIX&lt;/p&gt;
&lt;p&gt;SIX&lt;/p&gt;
&lt;p&gt;SIX&lt;/p&gt;
&lt;p&gt;SIX&lt;/p&gt;
&lt;p&gt;SIX&lt;/p&gt;
&lt;/li&gt;
&lt;li class='footerSiteLinkBlock' style='background:#FFFF00;'&gt;
&lt;h2&gt;FOUR&lt;/h2&gt;
&lt;p&gt;FOUR&lt;/p&gt;
&lt;p&gt;FOUR&lt;/p&gt;
&lt;p&gt;FOUR&lt;/p&gt;
&lt;/li&gt;
&lt;li class='footerSiteLinkBlock' style='background:#FF0000;'&gt;
&lt;h2&gt;TWO&lt;/h2&gt;
&lt;p&gt;TWO&lt;/p&gt;
&lt;p&gt;TWO&lt;/p&gt;
&lt;p&gt;TWO&lt;/p&gt;
&lt;p&gt;TWO&lt;/p&gt;
&lt;p&gt;TWO&lt;/p&gt;
&lt;p&gt;TWO&lt;/p&gt;
&lt;p&gt;TWO&lt;/p&gt;
&lt;p&gt;TWO&lt;/p&gt;
&lt;p&gt;TWO&lt;/p&gt;
&lt;p&gt;TWO&lt;/p&gt;
&lt;p&gt;TWO&lt;/p&gt;
&lt;p&gt;TWO&lt;/p&gt;
&lt;p&gt;TWO&lt;/p&gt;
&lt;p&gt;TWO&lt;/p&gt;
&lt;p&gt;TWO&lt;/p&gt;
&lt;p&gt;TWO&lt;/p&gt;
&lt;p&gt;TWO&lt;/p&gt;
&lt;p&gt;TWO&lt;/p&gt;
&lt;/li&gt;
&lt;li class='footerSiteLinkBlock' style='background:#00FFFF;'&gt;
&lt;p&gt;ONE&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@WebJoelMar 12.2007 — I looked at both your posts' code and have to admit that I have no idea what you are trying to acheive or what the problem here is. ? Can you explain this any better?
Copy linkTweet thisAlerts:
@m9dauthorMar 13.2007 — Sorry WebJoel. I probably could do a better job describing what I am trying to do and what is displaying incorrectly.

I am building a footer nav bar that will have four columns of links, text and images across the bottom of the page. Originally I used float:left on four DIVs to create the four column layout. It worked in all browsers I tested except in Netscape. In NS 8.1, the 4th column on the right side of the page displayed under the 1st column all the way on the left side of the page. In NS 7.1, the 4 columns displayed properly, but there was a large margin, within the #footer DIV that stretched the backgorund color too far below all the columns. The margin is also equal in height to the 4th column DIV.

The second example of code I provided, used an UL to layout the 4 columns rather than DIVs. I also used float:left values in all the parent elements above the floated columns. That worked better than the overflow:hidden values that I originally had. This example works in every browser I have looked at and was hoping that if someone noticed any problems, they could let me know.

I am sorry that I can not post a link to view, but the code I provided has been stripped to show just the elements of the footer, that I am having a problem with.
×

Success!

Help @m9d spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...