gpt4 book ai didi

html - 如何在不使用类或伪类的情况下选择表格行?

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

我想在不使用伪类或不对该行应用类的情况下选择表格的第三行(这更多是为了练习兄弟运算符的工作方式)。

但它也适用于第四行和后续行。

tbody > tr + tr + tr {
color: blue;
}
    <table>
<tbody>
<tr><td>Hello</td></tr>
<tr><td>World</td></tr>
<tr><td>Should be blue</td></tr>
<tr><td>Should not be blue</td></tr>
</tbody>
</table>

最佳答案

没有选择器?那么您可以在 tbody > tr + tr + tr + tr 上使用 color: initial(您可以重置您在此选择器中的第三个 tr 使用 initial - 请参见下面的演示:

tbody > tr + tr + tr {
color: blue; /* styles for the third row */
}
tbody > tr + tr + tr + tr{
color: initial; /* reset all the styles applied in the third row here */
}
<table>
<tbody>
<tr><td>Hello</td></tr>
<tr><td>World</td></tr>
<tr><td>Should be blue</td></tr>
<tr><td>Should not be blue</td></tr>
</tbody>
</table>

关于html - 如何在不使用类或伪类的情况下选择表格行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55002038/

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