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

บทบาทของ CSS :not(selector) Selector


เลือกทุกอย่างยกเว้น selector ที่ระบุ

ใช้ :not(selector) เพื่อเลือกองค์ประกอบที่ ไม่ตรงกับ 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>