:not 否定伪类在优先级计算中不会被看作是伪类. 事实上, 在计算选择器数量时还是会把其中的选择器当做普通选择器进行计数.

这是一块CSS代码:

div.outer p {
  color:orange;
}
div:not(.outer) p {
  color: blueviolet;
}

当它被应用在下面的HTML时:

<div class="outer">
  <p>This is in the outer div.</p>
  <div class="inner">
    <p>This text is in the inner div.</p>
  </div>
</div>

会在屏幕上出现以下结果:

css :not(否定伪类)用法

相关文章:

  • 2021-05-11
  • 2021-05-14
  • 2021-12-12
猜你喜欢
  • 2021-08-07
  • 2022-12-23
  • 2021-12-06
  • 2022-12-23
  • 2021-11-09
  • 2022-12-23
  • 2021-06-10
相关资源
相似解决方案