gpt4 book ai didi

html - 放置 tr :nth-child(even) inside a table tag

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

我正在尝试将 tr:nth-child(even) 放入表格标签中。我不希望它全局化。

示例:

<table style= "{tr:nth-child(even) = background-color: #c2ddf2;}"> 
<tr><th>One</th><th>Two</th><th>Three</th><th>Four</th></tr>
<tr><th>this</th><th>should</th><th>be different</th><th>colors</th></tr>
<tr><th>this should</th><th>be same</th><th>colors as</th><th>first row</th></tr>
</table>

最佳答案

只需向表中添加一个类即可!

.special tr:nth-child(even) {
background-color: #c2ddf2;
}
<table class="special"> 
<tr><th>One</th><th>Two</th><th>Three</th><th>Four</th></tr>
<tr><th>this</th><th>should</th><th>be different</th><th>colors</th></tr>
<tr><th>this should</th><th>be same</th><th>colors as</th><th>first row</th></tr>
</table>
<hr>
<table class="notspecial">
<tr><th>One</th><th>Two</th><th>Three</th><th>Four</th></tr>
<tr><th>this</th><th>should</th><th>be different</th><th>colors</th></tr>
<tr><th>this should</th><th>be same</th><th>colors as</th><th>first row</th></tr>
</table>

关于html - 放置 tr :nth-child(even) inside a table tag,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46957570/

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