Changing background colour of tr element on mouseover

前端 未结 9 928
一向
一向 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:31

    You could try:

    tr:hover {
        background-color: #000;
    }
    
    tr:hover td {
        background-color: transparent; /* or #000 */
    }
    

    JS Fiddle demo.

提交回复
热议问题