gpt4 book ai didi

css - 在一个复杂选择器中选择两个类

转载 作者:太空宇宙 更新时间:2023-11-04 06:09:52 24 4
gpt4 key购买 nike

给定两个又长又复杂的选择器,例如

.question-number td:first-child > span[...]
.question-text td:first-child > span[...]

有没有办法将两者合并,使得长后缀不需要重复?类似的东西(尽管这不是有效的 CSS)

(.question-number | .question-text) td:first-child > span[...]

最佳答案

如果你只有那两个包含单词question的类,你可以考虑attribute selector如下所示:

[class*=question] td:first-child>span {
color: red;
}
<table>
<tr class="anoher-class">
<td><span>some text</span></td>
</tr>
<tr class="question-number">
<td><span>some text</span></td>
</tr>
<tr>
<td><span>some text</span></td>
</tr>
<tr class="question-text">
<td><span>some text</span></td>
</tr>
</table>

关于css - 在一个复杂选择器中选择两个类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56516256/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com