Previous Message
Next Message

Re: [css-d] Weird margin in IE 6

Sent by Michael Landis on 25 July 2003 16:04


In response to an earlier post from Robert Nyman[1] about doubled margins
on the left side of a left floated div, I had suggested adding an
IE-specific rule to counteract this. In an off-list e-mail, Philippe
Wittenbergh pointed out that this double-margin bug does not occur on the
Mac, so I wanted to correct my original post (which, unfortunately, I had
already deleted from my e-mail, but is available on the private
archive[2]).

The original style provided by Robert was

div#leftColumnWideDiv{
 float:left;
 width:296px;
 margin:0px 10px;
 padding:0px;
 border:1px solid red;
}

To fix the left margin, I had originally suggested to include another
style, using the * html hack[3]:

* html div#leftColumnWideDiv{
 margin-left: 5px;
}

Now, to keep IE Mac from seeing this, we need to add another property
declaration that is only visible to IE Mac. It gets pretty ugly -- it uses
a backslash to hide it from IE 5.x PC, and an empty comment to hide it from
IE 6 PC[4] -- but here goes:

* html div#leftColumnWideDiv {
 margin-left: 5px;
 ma\rgin-left /**/: 10px;
}

IE Mac will read the last property there, restoring the proper margin. The
final style set (altogether) looks as follows:

div#leftColumnWideDiv{
 float:left;
 width:296px;
 margin:0px 10px;
 padding:0px;
 border:1px solid red;
}

* html div#leftColumnWideDiv {
 margin-left: 5px;
 ma\rgin-left /**/: 10px;
}

It ain't pretty, but it works!

Thanks again, Philippe, for pointing this out to me.

MikeL

[1] http://archivist.incutio.com/viewlist/css-discuss/28763
[2] http://www.css-discuss.org/mailman/private/css-d/2003-July/009948.html
[3] http://www.info.com.ph/~etan/w3pantheon/style/modifiedsbmh.html
[4] http://www.info.com.ph/~etan/w3pantheon/style/commentbugs.html

______________________________________________________________________
css-discuss [EMAIL-REMOVED]]
http://www.css-discuss.org/mailman/listinfo/css-d
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
Previous Message
Next Message

Possibly related: