Damn IE! IE8 hack
Miercuri, August 25th, 2010So there you have it, a nice clean code, you’re happy you got rid of IE6 (as much as it’s possible, ’cause sometimes you still have to apply fixes for those as well) only to realize problems still appear.
I was quite surprised to discover IE8 is not rendering correctly a margin, as in my latest projects I had no conflicts between Firefox and IE. Soo, to my surprise, a margin-top seemed to be a problem for IE8. em or % didn’t fixed the problem so I had to consider hacks. But what hacks?! There aren’t many out there that will fix IE8 problems only.
For IE7 and lower you can use the * hacks
body {
color: red;
*color: green;
}
But IE8 will ignore the star hack.
After some lost time, I discovered that there is a hack for IE8 as well. Actually multiple, but just one of them all worked for me:
body {
color: red;
color /*\**/:green\9;
}
So, one needs to place /*\**/ before the: and \9 before ;
Works for size as well, in my case the damn margin:
menu {
margin-top: 20px;
margin-top /*\**/: 40px\9;
}
Hope this will help others and spare them of lost time.






