Changing background colour of tr element on mouseover

前端 未结 9 896
一向
一向 2021-02-01 13:00

I want to have my table rows highlighted on mouse over, but I have yet to find a way to do it that isn\'t using Javascript. Is this not possible in CSS?

I\'ve tried this

9条回答
  •  野的像风
    2021-02-01 13:42

    This will work:

    tr:hover {
        background: #000 !important;
    }
    

    If you want to only apply bg-color on TD then:

    tr:hover td {
        background: #c7d4dd !important;
    }
    

    It will even overwrite your given color and apply this forcefully.

提交回复
热议问题