作者:罗罗罗罗罗棋辉 | 来源:互联网 | 2023-06-04 10:29
如何将特定的css专门应用于h2 :: after,然后还要有h2 :: before?
.region-sidebar-second .block > h2::after,.region-content .block > h2:after {
content: "";
display: block;
width: 30px;
margin-bottom: 1.25rem;
margin-top: 0.75rem;
border: 0.5px solid #252525;
position: relative;
}
#block-block-51 h2::before{
padding-right: 5px;
content: "\f02d";
font-family: "Font Awesome 5 Pro",sans-serif;
font-weight: 900;
}
::after_selector_for_those_h2_that_have_a_::before{
left:2rem;
}
您不能,至少现在还不能。这将需要选择器来选择具有before
伪元素(不存在)的元素。选择器仅适用于DOM中可用的内容。
有一个工作草案可以通过pseudo-class selector :has()
启用它。它看起来如下:
element:has(::before)::after
但是,从文档中
在当前规范中:没有被标记为实时选择器配置文件的一部分,这意味着它不能在样式表中使用;仅具有document.querySelector()
之类的功能。