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.