Link entire table row?

后端 未结 8 1228
后悔当初
后悔当初 2020-12-01 03:43

I know it is possible to link an entire table cell with CSS.

.tableClass td a{
   display: block;
}

Is there a way to apply a link to an en

相关标签:
8条回答
  • 2020-12-01 04:17

    To link the entire row, you need to define onclick function on your row, which is <tr>element and define a mouse hover in the CSS for tr element to make the mouse pointer to a typical click-hand in web:

    In table:

    <tr onclick="location.href='http://www.google.com'">
    <td>blah</td>
    <td>blah</td>
    <td><strong>Text</strong></td>
    </tr>
    

    In related CSS:

    tr:hover {
    cursor: pointer;
    }
    
    0 讨论(0)
  • 2020-12-01 04:18

    I feel like the simplest solution is sans javascript and simply putting the link in each cell (provided you don't have massive gullies between your cells or really think border lines). Have your css:

    .tableClass td a{
       display: block;
    }
    

    and then add a link per cell:

    <table class="tableClass">
        <tr>
            <td><a href="#link">Link name</a></td>
            <td><a href="#link">Link description</a></td>
            <td><a href="#link">Link somthing else</a></td>
        </tr>
    </table>
    

    boring but clean.

    0 讨论(0)
提交回复
热议问题