gpt4 book ai didi

html - 如何使 否决 背景色?

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

如果我将偶数行设为红色,将第二列设为蓝色,则交叉点变为红色。

我正在尝试将整个第二列设为蓝色。

tr:nth-of-type(2n)
{
background: red;
}
col:nth-of-type(2)
{
background: blue;
}
<h1>Make <s>cell 17</s> the whole second column blue</h1>
<p>Even if the table has 9999 other rows, which have cells with random rowspans...</p>

<table>

<colgroup>
<col>
<col>
</colgroup>

<tr><td>1<td rowspan="3">2<td>3<td rowspan="2">4<td>5
<tr><td>6<td>8<td rowspan="2">10
<tr><td>11<td>13<td>14
<tr><td>16<td rowspan="2">17<td>18<td>19<td>20
<tr><td>21<td>23<td>24<td>25

</table>

最佳答案

答案已更新

您可以定位 td[rowspan] 以确保所有 rowspans 都获得背景色。请参阅更新的代码段。

tr:nth-of-type(2n)
{
background: red;
}

td[rowspan] {
background: blue;
}
<h1>Make <s>cell 17</s> the whole second column blue</h1>
<p>Even if the table has 9999 other rows, which have cells with random rowspans...</p>

<table>

<colgroup>
<col>
<col>
</colgroup>

<tr><td>1<td rowspan="3">2<td>3<td>4<td>5
<tr><td>6<td>8<td>9<td>10
<tr><td>11<td>13<td>14<td>15
<tr><td>16<td rowspan="2">17<td>18<td>19<td>20
<tr><td>21<td>23<td>24<td>25

</table>

关于html - 如何使 <col> 否决 <tr> 背景色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41149845/

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