1. 程式人生 > >css :not(否定偽類)用法

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>

會在螢幕上出現以下結果: