javascript - 对于某些情况,如 Internet Explorer 特定的 CSS 或 Internet Explorer 特定的 JavaScript 代码,如何仅针对 Internet Explorer 10?

标签 javascript html css internet-explorer-10 conditional-comments

对于某些情况,如 Internet Explorer 特定的 CSS 或 Internet Explorer 特定的 JavaScript 代码,我如何仅针对 Internet Explorer 10?

我试过了,但它不起作用:

<!--[if IE 10]>    <html class="no-js ie10" lang="en"> <![endif]-->
<!--[if !IE]><!--> <html lang="en" class="no-js"> <!--<![endif]-->

Internet Explorer 10 会忽略条件注释并使用 <html lang="en" class="no-js">而不是 <html class="no-js ie10" lang="en"> .

最佳答案

我不会使用 JavaScript navigator.userAgent$.browser (使用 navigator.userAgent),因为它可以被欺骗。

针对 Internet Explorer 9、10 和 11(注意:也是最新的 Chrome):

@media screen and (min-width:0\0) { 
    /* Enter CSS here */
}

以 Internet Explorer 10 为目标:

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

以边缘浏览器为目标:

@supports (-ms-accelerator:true) {
  .selector { property:value; } 
}

来源:

关于javascript - 对于某些情况,如 Internet Explorer 特定的 CSS 或 Internet Explorer 特定的 JavaScript 代码,如何仅针对 Internet Explorer 10?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9900311/

相关文章:

javascript - 展平数组并保留索引作为其位置值

javascript - rowclick 事件修改 dojo 网格中的下拉值

javascript - 06 :34:23 and 02:45:55 这两个时间如何求差

PHP 动态裁剪和调整图像大小

css - 如何计算网格模板行的最大高度 : auto?

javascript - 如何将幻灯片放映图像对齐到 div 标签内的中心

html - 带有 2 个响应列的 Bootstrap 4 流体 Flex 行

javascript - Extjs培训

javascript - 如何使用 Python AES 解密以 Javascript 加密的数据?

javascript - HTML 表上的 .filter 不返回任何数据 - JavaScript