1
我有一個包含兩個單元格的表格行。我如何做到這一點,當我盤旋行,只有第一個表格單元格的背景改變顏色?將CSS樣式應用於行懸浮的第一個表格單元格
#formTable tr:hover {
background:red; // only want the first cell to change...
// ...this will do the whole row
}
我有一個包含兩個單元格的表格行。我如何做到這一點,當我盤旋行,只有第一個表格單元格的背景改變顏色?將CSS樣式應用於行懸浮的第一個表格單元格
#formTable tr:hover {
background:red; // only want the first cell to change...
// ...this will do the whole row
}
這應該工作:
#formTable tr:hover td:first-child {
background:red;
}
:第一胎:https://developer.mozilla.org/en-US/docs/CSS/:first-child
這隻會改變第一行的第一個單元格:
#formTable tr:first-child:hover td:first-child{
background-color: red;
}
這將更改任何行的第一個單元格:
您應該將解決方案作爲答案發布,然後接受它。 –