表样式-td:hover规则是否可以覆盖tr:hover?

I was wondering if it's possible to have a table styled with :hover background rules for both a tr and a td with certain class so that when the particular td is hovered on, only that element gets the background applied and not the tr it's within.

因此,例如:

tr:hover {
    background: blue;
}
td.something:hover {
    background: yellow;
}
<table>
    <tr>
        <td></td>
        <td></td>
        <td class="something"></td>
    </tr>
<table>

Here I'd like the table to highlight the row if the first two td elements are hovered, but not on the third td with the something css class.

I was wondering if the :not selector could help somehow, but I haven't come up with a way yet. Is this possible?

谢谢

评论
  • yvero
    yvero 回复

    !important is maybe the keyword you need. But I think it is not what you are intentionally asking for.