使用 CSS 为每个非指定元素设置样式
cssweb developmentfront end technology更新于 2025/6/4 21:32:17
要为每个非指定元素设置样式,请使用 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>
相关文章
有用资源
css 参考教程 - 该教程包含有关 css 的更多信息:https://www.cainiaomax.com/css/

