如何在CSS中检测IE和Edge浏览器? [英] how to detect IE and Edge browsers in CSS?

查看:507
本文介绍了如何在CSS中检测IE和Edge浏览器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否存在检测CSS中IE和Edge浏览器的标准方法?我在javascript文件中看到了检测到的响应,但是我正在CSS中寻找一个

Is there an standard way to detect IE and Edge browsers in css? I saw responses for detecting in javascript file but I am looking for one in css

推荐答案

对于IE 9及更低版本,请加载条件样式表:

For IE 9 and lower, load a conditional stylesheet:

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

IE 10及更高版本不支持此功能,因此您必须使用媒体查询:

IE 10 and up doesn't support this, so you have to use media queries:

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

对于Edge 12-15:

For Edge 12-15:

@supports (-ms-accelerator:true) {
   /* Edge 12+ CSS */ 
}

编辑

对于Edge 16 +

For Edge 16+

@supports (-ms-ime-align:auto) {
    /* Edge 16+ CSS */ 
}

这篇关于如何在CSS中检测IE和Edge浏览器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆