Link entire table row?

后端 未结 8 1260
后悔当初
后悔当初 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:01

    Use the ::before pseudo element. This way only you don't have to deal with Javascript or creating links for each cell. Using the following table structure

    Cell Cell Cell

    all we have to do is create a block element spanning the entire width of the table using ::before on the desired link (.rowlink) in this case.

    table {
      position: relative;
    }
    
    .rowlink::before {
      content: "";
      display: block;
      position: absolute;
      left: 0;
      width: 100%;
      height: 1.5em; /* don't forget to set the height! */
    }
    

    demo

    The ::before is highlighted in red in the demo so you can see what it's doing.

提交回复
热议问题