对于某些情况,如 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/