Search

9/24/2009

Ultimate IE6 Cheatsheet: How To Fix 25+ Internet Explorer 6 Bugs

Ultimate IE6 Cheatsheet: How To Fix 25+ Internet Explorer 6 Bugs
Definitive Guide to Taming the IE6 Beast

Fix relative positioning
Using position:relative in your designs is perhaps the easiest way to mess things up in IE6. Modern browsers display relatively positioned nested elements without issue, but IE6 frequently chokes up on even slightly complicated layouts. Fortunately, the solution is as easy as triggering hasLayout by adding zoom:1; to each relatively positioned element:

.selector {
position: relative;
}
* html .selector {
zoom: 1;
}

Note that you should not apply zoom:1; to any inline elements. Doing so will cause IE6 to treat them as block elements. Keep this in mind for the following solutions as well.

Fix negative margins
Negative margins are useful in a variety of scenarios, and most browsers handle them with no problem whatsoever. Unfortunately, IE6 doesn’t like negative margins unless you apply relative positioning to the target element:

.selector {
margin: -1.5em;
}
* html .selector {
position: relative;
zoom: 1;
}


Note the addition of the zoom:1; declaration, which is required because of the relative positioning. Ain’t IE great?

Fix overflow problems
Fix overflow problems

Using the overflow in IE6 will sometimes lead to unexpected, unexplainable display issues. Fortunately, we can resolve many overflow-related display problems by triggering hasLayout via — yep, you guessed it — zoom:1;. Here is an example:

.selector {
overflow: hidden
}
* html .selector {
zoom: 1;
}


Another strange overflow-related issue is observed when font-style:italic; expands the width of its parent element. Thankfully, this nuance is easily resolved by applying the following CSS to the parent element:

* html .selector {
overflow-x: hidden;
}

沒有留言: