gpt4 book ai didi

CSS 类在未设置的地方被拾取

转载 作者:太空宇宙 更新时间:2023-11-03 21:03:16 25 4
gpt4 key购买 nike

这个类制作了一个表格,表格的行颜色成对交替(两个灰色,两个白色,等等):

.table-striped-two-rows tbody tr:nth-child(4n+1), tbody tr:nth-child(4n+2) {
background-color: rgba(0, 0, 0, 0.05);
}

问题是它也会影响没有 class="table-striped-two-rows" 的表格。

我怎样才能将样式包含在带有类的表格中?

最佳答案

您还需要为 4n + 2 行指定祖先,以限制选择器的范围

.table-striped-two-rows tbody tr:nth-child(4n+1), 
.table-striped-two-rows tbody tr:nth-child(4n+2) {
background-color: rgba(0, 0, 0, 0.05);
}

关于CSS 类在未设置的地方被拾取,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57270438/

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