转载自:http://digau.cn/archives/958
因为不同浏览器对W3C标准的支持不一样,各个浏览器对于页面的解释呈视也不尽相同,比如IE在很多情况下就与FF存在3px的差距,对于这些差异性,就需要利用css 的hack来进行调整,当然在没有必要的情况下,最好不要写hack来进行调整,避免因为hack而导致页面出现问题。
1、 IE6、IE7、Firefox之间的兼容写法:
写法一:
IE都能识别*;标准浏览器(如FF)不能识别*;
IE6能识别*,但不能识别 !important,
IE7能识别*,也能识别!important;
FF不能识别*,但能识别!important;
根据上述表达,同一类/ID下的CSS hack可写为:
.searchInput {
background-color:#333;/*三者皆可*/
*background-color:#666 !important; /*仅IE7*/
*background-color:#999; /*仅IE6及IE6以下*/
}
一般三者的书写顺序为:FF、IE7、IE6。
IE6可识别“_”,而IE7及FF皆不能识别,所以当只针对IE6与IE7及FF之间的区别时,可这样书写:
.searchInput {
background-color:#333;/*通用*/
_background-color:#666;/*仅IE6可识别*/
}
.searchInput {
background-color:#333;/*通用*/
_background-color:#666;/*仅IE6可识别*/
}