Forum Moderators: not2easy

Message Too Old, No Replies

3px ie float bug issue

can't solve 3px ie float bug

         

rogersf

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

10+ Year Member



Hi,
I've done a lot of searching about the 3px bug yet nothing seems to
solve the following simple layout. I have the Holly Hack added but
still makes no difference, in IE6 I still get a gap to the right of
the floated div. Am I missing something?
Thanks,
Roger

#nav {
float: left;
width: 200px;
background: red;
height: 1%;

}

#main {
width: 200px;
height: 200px;
margin-left: 200px;
background: #ccc;

}

<body>
<div id="nav">
<p>left nav</p>
</div>

<div id="main">
</div>
</body>

rogersf

4:23 am on Mar 5, 2007 (gmt 0)

10+ Year Member



From another forum I found out that if i float both divs it solves the problem, since they're both fixed width. I'd still love to know a workaround if i just had the float div and a fixed margin div.

Setek

1:17 am on Mar 6, 2007 (gmt 0)

10+ Year Member



Position is Everything have a method for doing that, but it involves setting a fixed-height to every single element within the fixed-margin element sitting next to the floated element.

I haven't tested it but you can google for it.

Usually the way I fix the 3px text jog is to add

zoom: 1;
just for IE 6 so it forces the 3px to be uniform next to the fixed-margin element - though in pixel-perfect layouts, this isn't possible.

I usually avoid pixel-perfect layouts too :P

SuzyUK

10:09 pm on Mar 8, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



the 3px float jog seems to be fixed in IE7! woo hoo

rogersf (Welcome to WebmasterWorld btw..) yes it can be fixed in IE6 and below too.

It only ever does happen if a width or height is declared on the margined div. The width and height give the div "layout" or set hasLayout to true which is when IE's float model goes quirky (apparently not IE7 though)

So what you would have to for IE 6 and below is remove the margin off the right div - it doesn't need it, its quirk is that as soon as it has a width or height it's not floating properly anyway

if you do this you should see that nothing has changed it will still act as though it has that margin, and it still has the 3px gap then you can add a -3px margin to the left div to make the right div move over a bit.. you can't do this while it still has the unnecessary margin

so for IE6 and below,

<!--[if lt IE 7]>
<style type="text/css" media="screen">
#nav {margin-right: -3px;}
#main {margin-left: 0;}
</style>
<![endif]-->

this has been around for so long that I had no sites where it was even triggered, thanks for this post!

Suzy

[edited by: SuzyUK at 10:22 pm (utc) on Mar. 8, 2007]

rogersf

1:58 am on Mar 13, 2007 (gmt 0)

10+ Year Member



this is great news, suzyUK, thanks! I'll try it out.