Forum Moderators: not2easy

Message Too Old, No Replies

Internet Explorer 6.0 bug: dropping inline-float

If inline position and float direction is the same

         

mupo

9:17 am on Sep 15, 2005 (gmt 0)

10+ Year Member



Internet Explorer 6.0:
If inline position and float direction is the same,
then the float is dropped in a new line.
But if the element is left and floated right it is ok.

Is there any workaround, if i want to keep the logical order in the source code?

Example:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Internet Explorer 6.0 bug: dropping inline-float</title>

<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />

<style type="text/css">
li {width: 300px; border: 1px solid green}
img {float:right}
</style>

</head>

<body>
<h1>Internet Explorer 6.0 bug: dropping inline-float</h1>
<ul>
<li><a href="#">list item, floated image after</a><img src="#" width="20" height="20"></li>
<li><a href="#">list item, floated image after</a><img src="#" width="20" height="20"></li>
<li><img src="#" width="20" height="20"><a href="#">list item, floated image before</a></li>
</ul>

</body>

</html>

Thank you!

jetboy

11:36 am on Sep 15, 2005 (gmt 0)

10+ Year Member



IE6's float *positioning* behaviour is correct in the instance. Firefox does the same thing. The vertical position of a float is governed by its position in the source code.

The difference you're seeing is IE automatically allowing the <li>s to contain the floated <img>s, when in fact they should stick out.

If you add:

float: left;
clear: both;

to the <li> styles to replicate IE's incorrect default behaviour, Firefox will do the same. (We'll overlook the list bullets disappearing in IE when you do this. This really is an IE bug!)

So what are your options?

1. Use a -20px top margin on the <img> to drag it into the position you want.

2. Float the other elements inside the <li> out of the way:

a {
float: left;
}

3. Abandon the <img> element completely, and put a background image on the <li>:

li {
background: url(/images/image.gif) 100% 0 no-repeat;
}

Either add right padding to the <li> or right margin to the <a> to stop your text running over the image if you choose this option.

mupo

3:59 pm on Sep 15, 2005 (gmt 0)

10+ Year Member



I choosed the third option and put that image in the background.
By making a {display: block} the background image gets "clickable".

Thank you very much jetboy!