是否有办法选择与任意选择器匹配(或不匹配)的第 n 个子元素?例如,我想选择每个奇数表行,但在行的子集中:
table.myClass tr.row:nth-child(odd) {
...
}
| Row |
| Row |
| Row |
| Row |
但是 :nth-child() 似乎只是计算所有 tr 元素,无论它们是否属于“row”类,所以我最终得到了一个 even “行”元素而不是我正在寻找的两个元素。 :nth-of-type() 也会发生同样的情况。
谁能解释一下为什么吗?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号