Forum Moderators: not2easy

Message Too Old, No Replies

IE6 Adds 15px of white space after floated ULs?

         

markwm

4:11 pm on Mar 17, 2007 (gmt 0)

10+ Year Member



This is driving me bonkers...

IE 6 for some reason I cannot work out adds 15px of extra space at the right side of the last UL. Pushing the containing div 15px wider than it should be.

Any ideas?

<!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" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

<title>Title</title>

<style type="text/css">
* {
padding: 0;
margin: 0;
}

body {
color: white;
background-color: #EFEFEF;
}

.container {
width: 800px;
background-color: #FFFFFF;
margin-top: 10px;
height: 400px;

}

ul {
float: left;
width: 180px;
margin-right: 20px;
background-color: red;
}

li {
list-style-type: none;
}
</style>

</head>
<body>

<div class="container">

<ul>
<li>1</li>
</ul>

<ul>
<li>2</li>
</ul>

<ul>
<li>3</li>
</ul>

<ul>
<li>4</li>
</ul>

</div>

</body>
</html>

ytswy

5:59 pm on Mar 17, 2007 (gmt 0)

10+ Year Member



After playing with it a little I really don't get what is causing the problem. I did notice two things that seemed interesting:

1. If you add a fifth ul element -
<ul>
<li>5</li>
</ul>

Just before the </body> tag, the fifth element appears under the first and the margin on the forth one behaves like it should in IE.

2. If you replace the margin-right: 20px; style on the ul element with border-right: 20px white solid; you get the result you are aiming for.

ytswy

6:18 pm on Mar 17, 2007 (gmt 0)

10+ Year Member



Oh, and if you change the ul style rule to:

ul {
float: right;
width: 180px;
margin-left: 20px;
background-color: red;
}

You get the reverse of the original, but both browsers render the page the same as far as I can see.

markwm

8:37 pm on Mar 17, 2007 (gmt 0)

10+ Year Member



Yea, I noticed that it works when floated right, really is bizarre though why there's this extra space when floated left.

Surely there must be some logical answer? if it's not a bug

DanA

9:23 pm on Mar 17, 2007 (gmt 0)

10+ Year Member



Double margin bug?
add display:inline; in ul

markwm

7:54 pm on Mar 18, 2007 (gmt 0)

10+ Year Member



display: inline ruins the text in IE6/Win, check it. I can't figure out how to fix it either

markwm

9:13 pm on Mar 18, 2007 (gmt 0)

10+ Year Member



it seems display: inline on the li fixes it.