Make link in table cell fill the entire row height

后端 未结 10 1042
清酒与你
清酒与你 2020-11-27 03:54

I have a table of data and each cell is a link. I want to allow the user to click anywhere in the table cell and have them follow the link. Sometimes the table cells are m

10条回答
  •  情话喂你
    2020-11-27 04:46

    Following hack works [Tested on Chrome / Firefox / Safari] Have the same padding for td and anchor elements. And for anchor also have margin which is equal to -ve of padding value.

    HTML

    Hello

    CSS:

    td {                          
        background-color: yellow;                                                                              
        padding: 10px;                                                                                                            
    }  
    a {
        cursor:pointer;
        display:block;
        padding: 10px;
        margin: -10px;
    }
    

    Working Fiddle :http://jsfiddle.net/JasYz/

提交回复
热议问题