That question again...
In CSS, only the whole table can scroll, there's no easy way to keep the header or footer fixed.
Most answers here rely on Javascript, which makes resizing unbearable, or depend upon a fixed column width, which defeats the point of a <table>
, or a fixed table with.
Here's a CSS only solution that doesn't mess with the table's properties: https://codepen.io/Lasheimok/pen/jZqRvp
It uses Firefox's -moz-element
property to mirror the header and footer on empty div's outside the table.
So all of the table's styling still works - stretching width to content, alignment in headers, no delay while waiting for Javascript to redraw the table...
But there are still some problems:
- most obvious one: it's Firefox only
- when scrolling left and right, the table scrolls, but the header and footer don't
- there's an empty space at the bottom of the table where the footer is hidden
I haven't looked much into a Chrome version, but it does have a similar property that could be used instead.
Mostly I need help with the last two points: How to have the header scroll horizontally together with the rest of the table, and how to remove the empty space of the hidden footer at the bottom of the table?