I have a table that has border-collapse: separate
in order to have rounded corners.
I need to have a border around the entire table, but without any borders around internal cells.
Without border-collapse: separate
a border on the tbody
elements works! With separate
I can put a top border on th
elements, a bottom border on tr:last-child>td
elements, a left border on th:first-child,td:first-child
and a right border on th:last-child,td:last-child
. All this works great. I can even, with lots more code, place the border radii on the appropriate selectors too.
Now here comes the hard part. Sometimes, the last row of the table will have display:none
. I need to have the bottom border applied to the last visible row. As I mentioned before, when border-collapse
was collapse
, a border around <tbody>
works great! However, with separate
, borders around tbody
no longer work.
Is there a way, in CSS, to specify the last non-hidden tr
so I can put a border-bottom on it? Or do I have to use JavaScript?
EDIT
I am aware that getting the "last visible element" isn't really possible in general in CSS, however, I would love to know why bordering the tbody
fails with border-collapse:separate
and if there is a way to get back this cool behavior even with separate
.