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