CSS HACK区别IE6、IE7、IE8、Firefox兼容性

相信不少人,都特别清楚CSS HACK,而其中也是区别IE6、IE7、IE8、Firefox兼容性问题用的,CSS hack由于不同的浏览器,对CSS的解析认识不一样,因此会导致生成的页面效果不一样。

这儿做个总结,也是方便自己以后查阅。

1.分辨IE和非IE浏览器中

div{  
background:blue;/*非IE背景藍色*/  
background:red9;/*IE6、IE7、IE8背景紅色*/  
}  

2.分辨IE6,IE7,IE8和火狐

div{
background:blue;/*Firefox背景变蓝色*/  
background:red9;/*IE8背景变红色*/  
*background:black;/*IE7背景变黑色*/  
_background:orange;/*IE6背景变橘色*/  
}

3.(1)分辨IE6,IE7或火狐(由方法2得出)

div{  
background:blue;/*Firefox背景变蓝色*/  
*background:black;/*IE7背景变黑色*/  
_background:orange;/*IE6背景变橘色*/  
}  

3.(2)分辨IE6,IE7或火狐

div{  
background:blue;/*Firefox背景变蓝色*/  
*background:green!important;/*IE7背景变绿色*/  
*background:orange;/*IE6背景变橘色*/  
}  

4.分辨IE7或火狐

div{  
background:blue;/*Firefox背景变蓝色*/  
*background:green!important;/*IE7背景变绿色*/  
}  
原文地址:https://www.cnblogs.com/wanliyuan/p/3545609.html