Computer >> คอมพิวเตอร์ >  >> การเขียนโปรแกรม >> CSS

บทบาทของ CSS :not (ตัวเลือก) Selector


ใช้ตัวเลือก CSS :not(selector) เพื่อจัดรูปแบบทุกองค์ประกอบที่ไม่ใช่องค์ประกอบที่ระบุ คุณสามารถลองเรียกใช้โค้ดต่อไปนี้เพื่อใช้งาน :not selector

ตัวอย่าง

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