how to make a whole row in a table clickable as a link?

前端 未结 26 1937
粉色の甜心
粉色の甜心 2020-11-22 14:05

I\'m using Bootstrap and the following doesn\'t work:


    
        
            Blah Blah
           


        
26条回答
  •  时光取名叫无心
    2020-11-22 14:18

    One solution that was not mentioned earlier is to use a single link in a cell and some CSS to extend this link over the cells:

    table {
      border: 1px solid;
      width: 400px;
      overflow: hidden;
    }
    
    tr:hover {
      background: gray;
    }
    
    tr td {
      border: 1px solid;
    }
    
    tr td:first-child {
      position:relative;
    }
    
    a:before {
      content: '';
      position:absolute;
      left: 0;
      top: 0;
      bottom: 0;
      display: block;
      width: 400px;
    }
    First column Second column Third column
    First column Second column Third column

提交回复
热议问题