2010-10-24 131 views

回答

48

是的,一行是可能的,但不是一列。

tr:hover { 
    background-color: lightyellow; 
} 
2

如果你不關心Internet Explorer,在:hover CSS僞類適用於任何元素。

如果您對做了關心IE,您可以找到解決方法here

+3

IE7及更高版本支持:懸停 – 2014-05-09 12:41:44

+4

無人問津IE6了。 – nomad 2015-08-18 18:21:31

3

是的,它是可能的,但你必須在這裏不用擔心瀏覽器的兼容性是一個例子

<style type="text/css"> 
    .tbl {width: 640px;} 
    .tbl tr {background-color: Blue; height: 24px} 
    .tbl tr:hover {background-color: Red;} 
</style> 


<table class="tbl"> 
    <tr><td></td><td></td><td></td></tr> 
    <tr><td></td><td></td><td></td></tr> 
    <tr><td></td><td></td><td></td></tr> 
    <tr><td></td><td></td><td></td></tr> 
</table> 
0
<style type="text/css"> 
    tr.tr-hover-class:hover { 
     background: grey !important; 
    } 
</style> 

<table> 
    <tr class='tr-hover-class'></tr> 
</table> 
+0

這與功能上的接受答案有何不同? – lolbas 2018-02-23 12:31:17

+0

通過附加類實現,而不是覆蓋標準 – 2018-02-23 12:54:37

+0

接受答案的想法是使用':hover'僞類以及設置'background-color',並且答案與它沒有區別。 – lolbas 2018-02-23 12:56:05

相關問題