.selector {property /*\**/: value\9 }
这个IE6、IE7、IE8都能识别;但是IE8不能识别 “*” 和 “_” 的css hack;所以我们可以这样写hack:
.selector{width:300px;} /* 所有浏览器*/
.selector{width/*\**/:330px\9;} /* 所有浏览器IE浏览器 */
.selector{*width:310px;} /* IE7和IE6能识别,IE8和FF不能识别 */
.selector{_width:290px;} /* IE6能识别,IE7、IE8和FF不能识别*/
.selector{width:280px\0;} /* IE8 */
.selector{width:270px\0/IE8+9;} /* IE8+9 */
:root .selector{width:260px \0/IE9;}/* IE9 */
其它一些不常用的HACK:
Firefox 3 和 IE7 可識别:
selector, x:-moz-any-link, x:default {
/* Firefox 3 and IE7 rules here */
}
Safari 和 Opera 可識别:
@media all and (min-width: 0px) {
/* Safari and Opera rules here */
}
或者
@media screen and (-webkit-min-device-pixel-ratio:0){
/* Safari and Opera rules here */
}
.selector{
[color:#000; color:#f00 /* Safari & Chrome */
}
.selector{
[;color:red;]; /* chrome */
}
另外,IE5.5經已極少 人用了,不過萬一真有需要,可以用這個HACK:在屬性前面加”\”
.ie5hack{\width:100px;} /*無效*/
[參考阅读]