css :not(否定伪类)用法

: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>

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

猜你喜欢

转载自blog.csdn.net/u012501054/article/details/84624639
今日推荐