【问题标题】:How to change CSS for only IE?如何仅更改 IE 的 CSS?
【发布时间】:2020-11-12 18:40:44
【问题描述】:

我已经更改了我的代码,它可以在除 IE 之外的所有浏览器中完美呈现。无论如何只将IE的CSS更改为其他浏览器不会受到影响的地方?非常感谢您对此事的任何意见!

【问题讨论】:

标签: css internet-explorer sass


【解决方案1】:

您不能在 IE 中使用现代 css 属性,如 flexbox grid,您必须事先检查支持的属性的可用性。但是你可以使用-ms- prefix.e.g display: -ms-flexbox;

【讨论】:

    【解决方案2】:

    你想在 CSS 中只定位 IE 吗?如果是这样,您可以参考以下内容。

    对于 IE 9 及之前的版本,您需要加载一个条件样式表,如下所示:

    <!--[if IE]>
       <link rel="stylesheet" type="text/css" href="ie.css" />
    <![endif]-->
    

    对于 IE 10 及更高版本,它们不支持条件样式表,因此您必须使用如下媒体查询:

    @media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
       /* IE10+ CSS */
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-01
      相关资源
      最近更新 更多