tr:hover not working

后端 未结 13 1656
长发绾君心
长发绾君心 2020-12-08 09:27

I\'m trying to highlight (change background color) of the entire row when the mouse is hovering on a table row. I searched through the Net and it should be working, but it d

13条回答
  •  攒了一身酷
    2020-12-08 09:52

    Also, it matters in which order the tags in your CSS file are styled. Make sure that your tr:nth-child and tr:hover td are described before table's td and th. Like so:

    #tblServers {
      font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
      border-collapse: collapse;
      width: 100%;
    }
    
    #tblServers tr:nth-child(even){background-color: #f2f2f2;}
    
    #tblServers tr:hover td{background-color: #c1c4c8;}
    
    #tblServers td, #tblServers th {
      border: 1px solid #ffffd;
      padding: 8px;
    }
    
    #tblServers th {
      padding-top: 12px;
      padding-bottom: 12px;
      text-align: left;
      background-color: #4a536e;
      color: white;
    }
    

提交回复
热议问题