html - 在 IE 中隐藏 CSS 元素

标签 html css internet-explorer

我需要在我的 IE CSS 中隐藏一个背景元素。

这是css文件中的类

.navbar-header .nav #presentacion {
    background:url("../img/horiz-line.png") no-repeat scroll 108px 20px transparent;
    display: block;
    height: 20px;
    margin-top: 20px;
}

我想使用这种方法,在页面的头部部分插入 CSS 来隐藏这部分:

    <!--[if IE]>
          <style>
         .navbar-header .nav #presentacion {
         display: block;
         height: 20px;
         margin-top: 20px;
         background: none;}
    </style>
   <![endif]-->

它不工作,背景仍然显示在 IE 中,我做错了什么?

最佳答案

IE 10+ 不支持条件样式。所以你必须将它用于 IE10+:

<style>
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
    /* IE10+ styles */
  .navbar-header .nav #presentacion {
         display: block;
         height: 20px;
         margin-top: 20px;
         background: none;}
}
</style>

更多信息在这里:How do I target only Internet Explorer 10 for certain situations like Internet Explorer-specific CSS or Internet Explorer-specific JavaScript code?

关于html - 在 IE 中隐藏 CSS 元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12070499/

相关文章:

html - 事件按钮不起作用

php - 将一个简单的 html/css 页面转换为 wordpress

css - IE 在 Fieldset 中发出 min margin-top Legends

html - 如何使列从容器顶部开始,而不依赖于其他列?

php - 显示 PHP 表中的最新年份

javascript - 圆圈上的视频灯箱链接不起作用

javascript - 在 ASP.NET 中使用 CSS/Javascript 的弹出窗口

javascript - 单击转到模态部分

c++ - 从工具栏获取 Internet Explorer 中当前页面的地址

css - Internet 浏览器 CSS : Joomla Custom template