我知道选择器:not()
,但它不起作用,比如tr:not(tr:first-child):hover
. 我想为其他tr
s 设置样式,但不是第一个,因为它包含标题。我怎么能不使用id
or来做到这一点class
?
问问题
1285 次
4 回答
3
于 2013-10-09T01:39:23.883 回答
2
另一种选择是使用专门表示表格中标题单元格的th
元素。
例子
<table>
<thead>
<tr>
<th>Number</th>
<th>element</th>
</tr>
</thead>
<tbody>
<tr>
<td>4.1.1</td>
<td>html</td>
</tr>
<tr>
<td>4.2.1</td>
<td>head</td>
</tr>
</tbody>
</table>
于 2013-10-11T22:02:23.540 回答
1
使用相邻的兄弟组合器。作为奖励,它的支持范围比:not()
TR + TR { background-color: silver; }
TR + TR:hover { background-color: green; }
于 2013-10-09T01:37:20.103 回答
0
将您的标题放在 a中,然后使用<thead>
您的可样式行:<tbody>
tbody tr:hover { background: red }
内容是什么并不重要。
于 2013-10-12T05:46:34.257 回答