CSS 检测 IE 浏览器

<!--[if IE]>
<link href="ie.css" rel="stylesheet">
<![endif]--> <!--[if IE6]>
<style type="text/css">
/* styles for IE6 goes here */
</style>
<![endif]--> <!--[if lt IE7]>
<style type="text/css">
/* styles for IE7 goes here */
</style>
<![endif]--> <!--[if lte IE8]>
<style type="text/css">
/* styles for IE8 goes here */
</style>
<![endif]--> <!--[if gt IE9]>
<style type="text/css">
/* styles for IE9 goes here */
</style>
<![endif]--> <!--[if gte IE9]>
<style type="text/css">
<!-–[if IE 7]>
<!–- 如果IE浏览器版是7,调用ie7.css样式表- –>
<link rel="stylesheet" type="text/css" href="ie7.css" />
<![endif]–->
<!–-[if lte IE 6]>
<!–- 如果IE浏览器版本小于等于6,调用ie.css样式表 -–>
<link rel="stylesheet" type="text/css" href="ie.css" />
<![endif]–>
注意:默认的CSS样式应该位于HTML文档的首行,进行条件注释判断的所有内容必须位于该默认样式之后。
比如如下代码,在IE浏览器下执行显示为红色,而在非IE浏览器下显示为黑色。
<!-–[if IE]>
<style type="text/css">
body{
background-color: #F00;
}
</style>
<![endif]–->

/* Target IE 10 */
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
p {
color: red;
}
}

device-pixel-ratio

<!-- Target Safari and Chrome -->

@media screen and (-webkit-min-device-pixel-ratio:0) {
p {
color: red;
}
} <!-- Target Firefox --> @-moz-document url-prefix() {
p {
color: red;
}
} <!-- Target Opera --> x:-o-prefocus, p {
color: red;
}
var ms_ie = false;
var ua = window.navigator.userAgent;
var old_ie = ua.indexOf('MSIE ');
var new_ie = ua.indexOf('Trident/'); if ((old_ie > -1) || (new_ie > -1)) {
ms_ie = true;
} if ( ms_ie ) {
document.documentElement.className += " ie";
}

old IE

p {
color: red; /* All browsers */
color: red\9; /* IE8 and below */
*color: red; /* IE7 and below */
_color: red; /* IE6 */
}

refs

https://www.quirksmode.org/css/condcom.html

https://www.webhek.com/post/conditional-comments-in-ie11-10.html

https://www.4spaces.org/css-ie-browser-check/



xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


最新文章

  1. TeamCity : 配置第一个工程
  2. MySQL的create table as 与 like区别
  3. Unreal Engine Plugin management
  4. paper 99:CV界的明星人物经典介绍
  5. [水煮 ASP.NET Web API2 方法论](3-2)直接式路由/属性路由
  6. Oracle sql trace
  7. 添加点标注IMarkerElement
  8. provider: 命名管道提供, error: 40 - 无法打开 SQL Server 联系)
  9. JavaScript入门(一)
  10. ssm实现分页查询
  11. Android RecyclerView 快速平滑返回顶部
  12. Pandas 基础学习
  13. #学号 20175201张驰 《Java程序设计》第3周学习总结
  14. List泛型与DataTable相互转换
  15. vim 命令补充(1)
  16. python练习题-day14
  17. python 文件路径名,文件名,后缀名的操作
  18. CSS属性大全
  19. BFC(块级格式化上下文)
  20. day01_雷神_Python入门

热门文章

  1. 干货!上古神器 sed 教程详解,小白也能看的懂
  2. 使用pushplus+python实现亚马逊到货消息推送微信
  3. Pod和容器的LimitRange原理和实践总结
  4. Spring Boot 微服务应用集成Prometheus + Grafana 实现监控告警
  5. Prometheus监控Kafka
  6. Mysql数据库版本高低引起的group by问题
  7. typedef void (*sighandler_t)(int);
  8. Flink-v1.12官方网站翻译-P015-Glossary
  9. charles(2)MAC Charles关闭后无法上网
  10. linux(5)查看历史命令执行记录history