Forum Moderators: not2easy

Message Too Old, No Replies

floated element in IE

floated IE FireFox margin

         

chrislinzh

2:32 pm on Sep 27, 2005 (gmt 0)

10+ Year Member



I set an element with 5px margin without float, it looks good in IE and Firefox. If I set it with {float: left},IE add 3px at the leftside margin,but Firefox don't.
How to slove this problem?

benihana

2:48 pm on Sep 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



add :

display:inline;

after the

float:left;

chrislinzh

4:52 am on Sep 28, 2005 (gmt 0)

10+ Year Member



Yes,it works,thanks a lot

benihana

7:53 am on Sep 28, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Didnt have much time when i posted yesterday, but for the sake of clarity Im guessing IE was adding an extra 5px of margin to the left.

This is caused when you have a margin on the same side as you are floating towards, in this case 5px all round (including the left) and float:left;. In this circumstance IE doubles the margin on that side - making it 10px.

Adding display:inline; bizarrely fixes this bug, yet the element still retains its block status bought on by the float.