如何使用CSS定位范围内的特定文本

问题描述 投票:0回答:1

我有一个html:

<div class="test>

<span>Yellow</span>
<span>Blue</span>
<span>Purple</span>

</div>

我希望隐藏包含文本“黄色”和“紫色”的跨度。我可以用CSS做到吗?也许是属性?跨度没有课程,或者换句话说,它们就没有课程。

html css text attributes target
1个回答
0
投票
 .test span:nth-of-type(1) {
     // this gets you the first one
 }

 .test span:nth-of-type(2) {
     // this gets you the second one
 }

© www.soinside.com 2019 - 2024. All rights reserved.