定位所有而不是标题
target all not headings
我正在尝试编写一个 CSS 选择器来定位所有非标题元素(h1
、h2
、h3
、...)
我用谷歌搜索了 "all not headings 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 */
}
但我不想输入所有这些内容,我担心这会使我的代码难以导航。有更简单的方法吗?
链接 :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>
我正在尝试编写一个 CSS 选择器来定位所有非标题元素(h1
、h2
、h3
、...)
我用谷歌搜索了 "all not headings 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 */
}
但我不想输入所有这些内容,我担心这会使我的代码难以导航。有更简单的方法吗?
链接 :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>