gpt4 book ai didi

html - 表格中单行 元素中的背景颜色条纹

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

我有一个只有一行和 3 个单元格的表格。我正在寻找更改将有 3 条条纹的整行的颜色。我不确定该怎么做。

<table>
<tr>
<td>first cell</td>
<td>second cell</td>
<td>third cell</td>
</tr>
</table>

如果它是一个 div,我会在其中放置 3 个 div,并且我可以这样做:

    <style>
#someDiv{
border: 1px;
// background-color: grey;
width:100%;
height:102px;
}
#divthree{
background-color:green;
height:34px;
}
#divone{
background-color:#FF6600;
height:34px;
}
#divtwo{
background-color:white;
height:34px;
}
</style>

<div id="someDiv">
<div id="divone"></div>
<div id="divtwo"></div>
<div id="divthree"></div>
</div>

像这样的东西 http://jsfiddle.net/5mdEK/

结果如下:http://jsfiddle.net/H4Hr7/

最佳答案

td:nth-child(even) {background: #CCC}
td:nth-child(odd) {background: #FFF}

col:nth-child(2n) {background: #CCC}

参见: http://www.w3.org/Style/Examples/007/evenodd.en.html

关于html - 表格中单行 <tr> 元素中的背景颜色条纹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18213480/

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