tryin_to_learn — 2013-12-17T13:41:31-05:00 — #1
Is there a way to freeze several rows at the top of an HTML table so that the data rows scroll up under the header? I've seen solutions where you set specific widths for each of the tds but I'm hoping to allow the data in the tds to word-wrap for the most part. I may set some widths where I know the dimension (like where there are tools with 16px icons), but the larger columns will need to word-wrap. It's a multi-column, potentially multi-row table. It will have to work across platforms and browser, ya-da, ya-da. I've seen solutions that "come close", i.e., column width might be between 2 and 12 px off depending on the browser, but I'd really like to nail it, if possible. Any way to do this?
solidcodes — 2013-12-17T15:59:31-05:00 — #2
I think for the headers you can use like this,
pullo — 2013-12-17T16:45:37-05:00 — #3
My first response would be to use a plugin.
This one, for example, seems quite good: http://fixedheadertable.com/
Is there a reason why this would not work?
paulob — 2013-12-18T06:37:18-05:00 — #4
You can do something in CSS alone but there is limited styling capabilities of the fixed header due to the way it is moved.
This is an old demo (as you can see by browsers supported).
The effect is created by absolutely placing the table header content into some space at the top but the page is held open using a tfoot element to mirror the header instead.
For anything more complicated you would need a script such as the one that Pullo mentions above.
tryin_to_learn — 2013-12-18T09:42:22-05:00 — #5
Thanks, Paul and Pullo. I'll check into both of these and be back if I have questions.