CSS选择器需要建议

  • 本文关键字:选择器 CSS html css
  • 更新时间 :
  • 英文 :


我正在制作一个带有背景色的方框,上面有很多内容为此,我必须改变文本颜色,所有文本框内的背景色相反我已经使用了filter:invert(98%),现在的问题是它工作得很好,但使其他图像和图标倒转

主要的

现在我想只选择具有css文本的元素,因为我正在使用wp react块我无法控制js所以需要css解决方案

请注意,在实际项目中,main元素中有很多元素,它们的名字不同

下面是一个示例代码

.main {
background:black;
}
.main > * {
filter:invert(80%);
}
<div class="main">
<div class"text1">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets conta
</div>
<hr>
<div class"another_text">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets conta
</div>
</div>

这很简单,你也可以这样写CSS.main {背景:

span{
color:white;
padding:4%;
background:#000000ad
}
<div class="test"><span>Hello World</span></div>

}

最新更新