html - CSS :not() not working properly

标签 html css css-selectors

所以我有这样的代码结构:

.header-container a:not(.header-menu-right a) {
  display: none;
}
<div class="header-container">
  <div class="header-menu-right">
    <ul>
      <li><a href="#">link</a></li> 
        <!-- unimportant links -->
        <li><a href="#">link</a></li> 
          <!-- unimportant links -->
    </ul>
  </div>
  <a href="#">link</a> 
  <!-- important link -->
</div>

正如你从注释中看到的,我只希望 CSS 更改最后一个 a 标签。

我在这里做错了什么?

最佳答案

试试这个,就可以了:

.header-container > a {
    display:none;
}

谢谢!

关于html - CSS :not() not working properly,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39330378/

相关文章:

html - 将背景图像和自定义元素符号应用于 css 标题

javascript - 显示内容未定义

html - 问题居中DIV

asp.net - 鼠标悬停事件第二次不起作用

jquery - 上传后隐藏div背景图片

css - 文本长度的条件CSS

css - 你见过这样的CSS选择器吗?

javascript - Bootstrap 轮播类型错误 : e[g] is not a function

css - 为什么我无法在 Firefox 中对生成的内容进行绝对定位?

适用于具有两个类的元素的 CSS 选择器