Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to have a border around a table row in some way?

I'm trying to add borders around specific table rows which change it's colors when the mouse enters the row. However, I don't see a border at all unless using border-collapse:collapse; but I have to avoid border-collapse, since in some cases the border is visible left, right and at bottom but not on top (probably because I cannot have padding/margin when using border-collapse).

Is there a way to achieve this?

<table style="border-collapse:collapse;">
  <tr style="border:1px solid black">
    <td>Cell_1</td>
    <td>Cell_2</td>
  </tr>
</table>
like image 800
wdguru Avatar asked Sep 03 '25 14:09

wdguru


2 Answers

You can try using outline instead.

tr:hover {
    outline: 1px solid #999;
}

Have a look: http://jsfiddle.net/dWWkx/3/

like image 132
Yi Jiang Avatar answered Sep 05 '25 04:09

Yi Jiang


As far as I know you can't put a border on a table row, but you can on the table cell (<td>). With some creative border-right and border-left, with a cell-spacing of 0, you should be able to achieve the appearance of a border around the whole row.

like image 31
Pramendra Gupta Avatar answered Sep 05 '25 03:09

Pramendra Gupta