我正在尝试编写一个CSS选择器来定位所有不属于标题的元素(h1
,h2
,h3
,...)
我用谷歌搜索“所有不是标题css”和“not headings css”。没有任何相关内容,所以我决定在这里问。
我试过这样做:
body :not( h1, h2, h3, h4, h5, h6 ) {
/* yada yada yada */
}
我注意到这有效:
body :not(h1), body :not(h2), body :not(h3) /* et cetera */ {
/* yada yada yada */
}
但我宁愿不必输入所有内容,我担心它会使我的代码难以导航。有更简单的方法吗?
答案 0 :(得分:2)
链接:not
选择器
body *:not(h1):not(h2):not(h3) /* et cetera */ {
color:red
}
body *:not(h1):not(h2):not(h3)
/* et cetera */
{
color: red
}
<p>Red Text</p>
<h1>Black H1</h1>
<h2>Black H2</h2>