Quick CSS Hack for IE 7/8

November 7th, 2009 by junal Leave a reply »

As a developer you know how painful this IE shit is. If you are required to change a large amount of css classes just for IE 7/8 then it’s better to create a file with ie7.css or ie8.css and include the css file in your application. That will overwrite all classes for your IE 7/8 only and well don’t forget to keep “!important” to get the priority over existing properties. 

But, what if you just want to change only one or 2 properties just for IE? 
As an example let’s say you want to keep height of a DIV for IE8 in “auto” but for other browsers you want to keep it like height:10px; this is how we can do it…

.something {

    height:10px;  /* will work for rest of the browsers except IE8*/
    height /***/: auto9;   /* this will just change the IE8*/
 }

And what about IE7 ? just modifying the above class 
.something {
    height:10px;  /* will work for rest of the browsers except IE7*/
    *height: auto   /* this will just change the IE7*/
 }

Cool! i liked to get these hacks from online, certainly not a very good practice but hey, it’s not bad to use some hack instead of getting lost in nowhere? 

Advertisement
blog comments powered by Disqus
Get Adobe Flash playerPlugin by wpburn.com wordpress themes