简体   繁体   English

需要 CSS 选择器建议

[英]CSS selector suggestion needed

I am making a box with background color in it and lots of content over it for that I have to change text color off all texts inside box opposite to background color i have used filter:invert(98%) now the problem is it is working good but making other images and icons inverted as well我正在制作一个带有背景颜色的盒子,上面有很多内容,因为我必须更改与背景颜色相反的盒子内所有文本的文本颜色我使用了filter:invert(98%)现在问题是它正在工作很好,但也会使其他图像和图标倒置

main thing主要的事

now I wanted to select only elements with text with css since I am working with wp react for blocks I don't have much control with js so css solution is required for that thing现在我只想选择带有 css 文本的元素,因为我正在使用 wp react for blocks 我对 js 没有太多控制,所以那件事需要 css 解决方案

note that there are lots of elements inside main element in real project with various names请注意,在实际项目中,main 元素中有很多不同名称的元素

here is a example code below这是下面的示例代码

 .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>

it's simple, you can write css this way as well .main{ background:很简单,你也可以这样写 css .main{ background:

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

} }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM