简体   繁体   中英

How to make whole table cell clickable but vertical align text inside it - CSS

How to make whole table cell clickable but vertical align text inside it.

Alright it is achievable by making link display:block and setting line height.

But the problem is text may get 2 lines some times. So this way is not solution. Are there any other solution ?

thank you.

You could do this by adding a class to the cell you want to click and hooking this up using jquery such as

<td class="clickable">...</td>

your jquery...

$('.clickable').click(function() {
   alert('Table cell has been clicked');
 });

Yes you could do that but I usually need each cell to do something different or to send a different piece of data for each cell. So I use something like this.

<td onclick="update_calendar(1337317200);">19</td>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM