CSS :not (選擇器) 選擇器的作用


使用 CSS :not(selector) 選擇器對不是指定元素的所有元素進行樣式設定。你可以嘗試執行下面的程式碼來實現 :not 選擇器

示例

即時演示

<!DOCTYPE html>
<html>
   <head>
      <style>
         p {
            color: red;
         }
         :not(p) {
            color: blue;
         }
      </style>
   </head>
   <body>
      <h1>Heading 1</h1>
      <h2>Heading 2</h2>
      <h3>Heading 3</h3>
      <p>This is a paragraph.</p>
      <p>This is another paragraph.</p>
   </body>
</html>

更新於: 30-6-2020

296 次瀏覽

開啟你的 職業生涯

透過學習課程來獲得認證

開始學習
廣告
© . All rights reserved.