css在ie下各种hack写法,实现浏览器之间的兼容

来源:赵克立博客 分类: 前端开发 标签:css发布时间:2016-11-19 11:37:44最后更新:2016-11-19 11:49:00浏览:1785
版权声明:
本文为博主原创文章,转载请声明原文链接...谢谢。o_0。
更新时间:
2016-11-19 11:49:00
温馨提示:
学无止境,技术类文章有它的时效性,请留意文章更新时间,如发现内容有误请留言指出,防止别人"踩坑",我会及时更新文章

blob.png

ie系列css hack支持的写法

color:red !important; /* 除IE6外 */
_color:red; /* IE6支持 */
*color:red; /* IE6、IE7支持 */
+color:red; /*IE7支持*/
*+color:red; /* IE7支持 */
color:red\9; /* IE6、IE7、IE8、IE9支持 */
color:red\; /* 针对所有IE */
color:red\0; /* IE8、IE9支持 */
color:red\9\0; /*IE9支持*/

ie下专有标签识别方法

<!--[if lt IE 7 ]> <html class="ie6"> <![endif]-->
<!--[if IE 7 ]> <html class="ie7"> <![endif]-->
<!--[if IE 8 ]> <html class="ie8"> <![endif]-->
<!--[if IE 9 ]> <html class="ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html> <!--<![endif]-->
<!–[if IE 7]> = 等于 IE7
<!–[if lt IE 8]> = 小于 IE8(就是 IE7 或以下了啦)
<!–[if gte IE 8]> = 大于或等于 IE8 
<meta http-equiv="x-ua-compatible" content="ie=7" />
把上面这段代码放到<head>里面,在ie8里面的页面会按ie7的模式解析
<meta http-equiv="X-UA-Compatible" content="IE=edge">
把上面的这段代码放到<head>里面,会按当前系统的ie最高版本解析页面

Firefox/Opera/Webkit/Chrome/Safari 这些浏览器的兼容识别hack

这些最新的浏览器版本一般都支持css3,如果要兼容这些浏览器的早期旧的版本的话就加上下面对应的前缀

-moz-对应 Firefox, 
-webkit-对应 Safari and Chrome
-o- for Opera
-ms- for Internet Explorer



微信号:kelicom QQ群:215861553 紧急求助须知
Win32/PHP/JS/Android/Python