【问题标题】:css for ie without using conditional commentscss for ie 不使用条件注释
【发布时间】:2014-08-07 17:10:59
【问题描述】:

我开始了解这些针对 IE 的样式:

@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {  
   /* IE10-specific styles go here */  
}

@media screen and (min-width:0\0) {  
    /* IE9 and IE10 rule sets go here */  
}

我也想知道其他版本的ie。

我如何使用媒体查询仅 ie6、仅 ie7、仅 ie8、仅 ie9、小于或等于 ie10 等?

还有其他的技巧吗?

【问题讨论】:

  • 什么是“条件格式”?
  • 对不起,我的意思是有条件的评论是我的错误..

标签: css internet-explorer


【解决方案1】:

IE 不支持版本 8 及以下版本的媒体查询 - caniuse

这意味着媒体查询中的任何代码都将被 IE8 忽略-

所以不,您不能使用媒体查询来定位旧版本的 IE。

但是...

在 css 中还有其他针对旧版本 IE 的 hack....

这是this css-tricks article的摘录:

/* IE6 */
#once { _color: blue }

/* IE6, IE7 */
#doce { *color: blue; /* or #color: blue */ }

/* Everything but IE6 */
#diecisiete { color/**/: blue }

/* IE6, IE7, IE8 */
#diecinueve { color: blue\9; }

/* IE7, IE8 */
#veinte { color/*\**/: blue\9; }

/* IE6, IE7 -- acts as an !important */
#veintesiete { color: blue !ie; } /* string after ! can be anything */

【讨论】:

  • 我已经看到了。但想知道像我的问题一样使用媒体查询。不过谢谢。
猜你喜欢
  • 1970-01-01
  • 2014-04-02
  • 1970-01-01
  • 2016-07-22
  • 2013-01-01
  • 2011-02-04
  • 2012-05-07
  • 2012-02-16
  • 1970-01-01
相关资源
最近更新 更多