首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CSS选择器建议

CSS选择器建议
EN

Stack Overflow用户
提问于 2021-10-27 11:51:03
回答 1查看 58关注 0票数 0

我正在制作一个带有背景色的盒子,上面有很多内容,因为我必须改变所有与背景色相对的文本颜色,我现在使用的是filter:invert(98%),问题是它工作正常,但是其他图像和图标也被倒置了。

主事

现在,我只想选择带有css文本的元素,因为我正在使用wanted处理块,所以我对js没有太多的控制,所以需要css解决方案。

注意到,在实际项目中,主元素中有许多元素,具有不同的名称

下面是一个示例代码

代码语言:javascript
复制
.main {
background:black;
}

.main > * {
filter:invert(80%);
}
代码语言:javascript
复制
<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>

EN

回答 1

Stack Overflow用户

发布于 2021-10-27 12:04:35

很简单,您可以用这种方式编写css,也可以编写.main{背景:

代码语言:javascript
复制
span{
color:white;
padding:4%;
background:#000000ad
}
代码语言:javascript
复制
<div class="test"><span>Hello World</span></div>

}

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69738140

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档