这是桌子的样子:
table {
border-collapse: collapse;
}
<table border="1">
<tr>
<td rowspan="2">Text here</td>
<td>The row 1 text goes here</td>
</tr>
<tr>
<td>The row 2 text goes here</td>
</tr>
<tr>
<td rowspan="2">Text here</td>
<td>The row 1 text goes here</td>
</tr>
<tr>
<td>The row 2 text goes here</td>
</tr>
<tr>
<td rowspan="2">Text here</td>
<td>The row 1 text goes here</td>
</tr>
<tr>
<td>The row 2 text goes here</td>
</tr>
</table>
我想实现的是,当用户将鼠标悬停在其中一行上时,相邻的另一行以及用户悬停的行都会高亮显示。我试过这个:
table {
border-collapse: collapse;
}
table tr:nth-child(odd):hover {
background: #CCC;
}
table tr:nth-child(odd):hover + tr {
background: #CCC;
}
table tr:nth-child(even):hover {
background: #CCC;
}
<表格边框=“1”>
<td行span=“2”>此处显示文本</td>
<td>第1行文本位于此处</td>
</tr>
<tr>
<td>第2行文本位于此处</td>
<tr>
<td行span=“2”>此处显示文本</td>
<td>第1行文本位于此处</td>
<tr>
<td>第2行文本位于此处</td>
</tr>
<tr>
<tr>
<td>第2行文本位于此处</td>
</tr>
</表>
我想的是
<rowgroup>
.