[英]CSS Hover entire row as well as single cell
How do I add a hover style to highlight a row that the cursor is on as well as another hover class to highlight the one specific cell(diff color, etc) that the cursor is on? 如何添加悬停样式以突出显示光标所在的行以及另一个悬停类以突出显示光标所在的特定单元格(差异颜色等)?
HTML 的HTML
<table>
<tr>
<td> </td>
<td> </td>
</tr>
</table>
CSS 的CSS
tr:hover td {bg-color:; color:;} /** Highlights row**/
You will need something similar to this. 您将需要与此类似的东西。
tr:hover {background-color:#000; color:#ff0000;} <!-- row hover
tr td:hover {background-color:#CCC; color:#fff;} <!-- individual cell hover
改用
tr td:hover {bg-color:; color:;} /** Highlights row**/
If you want to color the specific row than one of the way is to give it class name and change the color when hover over that class 如果要给特定的行着色,一种方法是给它命名类名,然后将鼠标悬停在该类上时更改颜色
HTML 的HTML
<table border=1>
<tr class="first">
<td> some value</td>
<td>some value </td>
</tr>
<tr class="second">
<td>some value </td>
<td>some value </td>
</tr>
<tr class="second">
<td>some value </td>
<td>some value </td>
</tr>
</table>
CSS 的CSS
.first:hover {
color: red;
}
try running this code. 尝试运行此代码。 Here when you hover over first row it will change the color of first row.
在这里,当您将鼠标悬停在第一行上时,它将更改第一行的颜色。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.