html - 针对非 IE 浏览器和特定 IE 版本的有效条件注释

标签 html css internet-explorer conditional-comments

如何使用条件注释来定位

  1. 仅限 Internet Explorer

  2. 某些 IE 版本

  3. 某些 IE 版本和所有其他浏览器

  4. 没有 IE,只有其他浏览器

以一种验证的方式? ( validator.w3.org/ )

最佳答案

我测试了这些,它们是有效的 HTML。

重要提示:Only IE 5 through 9 support conditional comments.

<!-- 1. IE 5-9 only: -->

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


<!-- 2. Some IE versions -->

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


<!-- 3. Some IE versions, plus all non-IE browsers -->

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


<!-- 4. All browsers except IE 5-9 -->

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

关于html - 针对非 IE 浏览器和特定 IE 版本的有效条件注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33132856/

相关文章:

internet-explorer - 未识别的 404 未找到页面

internet-explorer - GWT 默认样式 IE 字体大小

jquery - Internet Explorer 不执行 jQuery.load (Firefox 执行)

jQuery,响应式设计 : how to change a class based on window size

html - 如何解决显示图像标题的 css 问题?

html - Bootstrap Span 偏移量和背景颜色,如何避免为偏移量着色?

html - 伪流式传输 MP4 文件

javascript - 如何计算选择 h3 的价格?

javascript - 允许用户一键加入特定游戏服务器的 HTML 代码

javascript - HTML - 使用按钮在新窗口中打开本地 PDF