简体   繁体   English

悬停在表格行上的效果

[英]Hover effect on table row

I have a table with a class applied and I want to add a hover effect to all rows with a specific class name. 我有一个应用了类的表,我想向具有特定类名的所有行添加悬停效果。 But this doesn't seem to work. 但这似乎不起作用。 Using chrome. 使用铬。 Must work in IE8 as well. 也必须在IE8中工作。 Can anyone help me get this working please? 有人可以帮我解决这个问题吗?

html -> html->

<table class="myTable">
<tr class="myRow">
    <td>1</td>
</tr>
<tr>
    <td>2</td>
</tr>

css -> CSS->

.myTable.myRow tr:hover td{
 background-color:red;   

} }

Here's a Fiddle 这是小提琴

You can just use this: 您可以使用以下命令:

.myRow:hover {
    background:red;   
}

fiddle 小提琴

You have applied the class slightly wrong change it to: 您已经将该类应用了轻微的错误,将其更改为:

.myTable tr.myRow:hover td{
     background-color:red;   
}

Reasoning being in your css you are saying find the class myTable that also has class myRow but its your tr element with the myRow class. 推理是在您的CSS中,您要说的是找到类myTable ,该类也具有myRow类,但是它是myRow类的tr元素。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM