I'm having a weird issue with IE and clearing floats. First, a VERY cut down version of my code:
In IE, the img surrounded by the red border is popped up on the same line as Al Bundy. In firefox, it appears to the right side of the blue bordered image - on the same line as Homer Simpson (where I'd expect it to be). Once the style on the blue bordered image is set to clear:left it seems that the red bordered image would not be able to jump back above what we've just cleared. I can band-aid fix the problem by putting a float-breaker div between Al Bundy's anchor and the <img> tags, but it causes a big gap in IE and looks fine in firefox (which also looks fine before the float-breaker so it's not really fixing anything). I'd really rather not have to add in even more empty markup as well, so a solution that doesn't utilize the extra float-breaker <div> would be preferred. Anybody know why IE isn't behaving?
I saw this behavior on both IE6 and IE7.
-kaht
[small](All puppies have now found loving homes, thanks for all who showed interest)[/small]
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<script type="text/javascript"></script>
<style type="text/css">
* {
padding:0px;
margin:0px;
}
body {
font-family:Tahoma, Arial;
font-size:8pt;
}
div.floatBreaker {
clear:both;
}
div#controls {
float:left;
width:280px;
padding:5px;
border:1px solid #888888;
}
div#controls div#userList a {
display:block;
float:left;
text-decoration:none;
color:#ff00ff;
width:185px;
padding-left:3px;
margin-left:3px;
border:1px solid #000000;
}
div#controls div#userList img {
border:0px;
cursor:pointer;
float:left;
margin-top:2px;
margin-left:3px;
height:11px;
width:11px;
border:1px solid #ff0000;
}
div#controls div#userList img.firstImg {
clear:left;
margin-left:0px;
height:9px;
width:9px;
border:1px solid #0000ff;
}
</style>
</head>
<body>
<div id="controls">
<div id="userList">
<a href="#">Al Bundy</a>
<!--
<div class="floatBreaker"></div>
-->
<img src="" class="firstImg" />
<img src="" />
<a href="#">Homer Simpson</a>
</div>
</div>
</body>
</html>
In IE, the img surrounded by the red border is popped up on the same line as Al Bundy. In firefox, it appears to the right side of the blue bordered image - on the same line as Homer Simpson (where I'd expect it to be). Once the style on the blue bordered image is set to clear:left it seems that the red bordered image would not be able to jump back above what we've just cleared. I can band-aid fix the problem by putting a float-breaker div between Al Bundy's anchor and the <img> tags, but it causes a big gap in IE and looks fine in firefox (which also looks fine before the float-breaker so it's not really fixing anything). I'd really rather not have to add in even more empty markup as well, so a solution that doesn't utilize the extra float-breaker <div> would be preferred. Anybody know why IE isn't behaving?
I saw this behavior on both IE6 and IE7.
-kaht
[small](All puppies have now found loving homes, thanks for all who showed interest)[/small]