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


使用 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>

更新於:2020 年 6 月 30 日

295 次瀏覽

開啟你的職業

透過完成課程獲得認證

開始
廣告