CSS 将鼠标悬停在 table 中时更改特定单元格的背景颜色
CSS Changing background colour of specific cell in table when hovering over it
我有一个包含三列的 table。当我将鼠标悬停在它上面时,我希望能够仅更改第三列的格式。
我希望能够结合
td:nth-child(3) {背景颜色:#ddd;}
和
td:hover {背景颜色:#ddd;}
我该怎么做?
为单元格指定一个 class 名称或 ID。
td[id="your id"]{...}
td[id="your id"]:hover{background-color: #ddd;}
我想这就是你想要的。
td:hover:nth-child(1) {background-color: #f5f5f5;}
td:hover:nth-child(2) {background-color: #ff0000;}
td:hover:nth-child(3) {background-color: #ddd;}
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</tbody>
</table>
干杯
我有一个包含三列的 table。当我将鼠标悬停在它上面时,我希望能够仅更改第三列的格式。
我希望能够结合
td:nth-child(3) {背景颜色:#ddd;}
和
td:hover {背景颜色:#ddd;}
我该怎么做?
为单元格指定一个 class 名称或 ID。
td[id="your id"]{...}
td[id="your id"]:hover{background-color: #ddd;}
我想这就是你想要的。
td:hover:nth-child(1) {background-color: #f5f5f5;}
td:hover:nth-child(2) {background-color: #ff0000;}
td:hover:nth-child(3) {background-color: #ddd;}
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</tbody>
</table>
干杯