CSS兼容性汇总

http://www.jb51.net/css/469020.html

CSS属性Hack

把属性hack分为 前缀属性hack和 后缀属性hack

CSS属性Hack(前缀)针对的浏览器
_color:red;IE6及其以下的版本
*color:red ;或者 +color:red;IE7及其以下的版本
CSS属性Hack(后缀)针对的浏览器
color:red\9;IE6/IE7/IE8/IE9/IE10版本
color:red\0;IE8/IE9/IE10版本
color:red\9\0;IE9/IE10
color:red!importantIE7/IE8/IE9/IE10及其他非IE浏览器

其实,现在越来越的公司,不太让兼容ie6了,现在比较关心的是ie8.910等高版本的浏览器,因此这里小强老师也总结了ie专属hack ,比如ie8等。

选择器Hack写法针对于的浏览器
@media screen\9{body { background: red; }}只对IE6/7生效
@media \0screen {body { background: red; }}只对IE8生效
@media \0screen\,screen\9{body { background: blue; }}只对IE6/7/8有效
@media screen\0 {body { background: green; }}只对IE8/9/10有效
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {body { background: orange; }}只对IE10有效

如果样式比较多,条件注释,是不错的选择:

IE条件注释语句

IE条件注释语句针对的浏览器版本
<!--[if lt IE 7]>内容<![endif]-->IE7 以下版本
<!--[if lte IE 7]>内容<![endif]-->IE7及以下版本(包含IE7)
<!--[if gt IE 7]>内容<![endif]-->IE7 以上版本
<!--[if gte IE 7]>内容<![endif]-->IE7及以上版本(包含IE7)
<!--[if !IE 7]>内容<![endif]-->非IE7版本
<!--[if !IE]><!-->您使用不是 Internet Explorer<!--<![endif]-->非IE浏览器