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?
I think for the headers you can use like this,
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?
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.
Thanks, Paul and Pullo. I'll check into both of these and be back if I have questions.
This topic is now closed. New replies are no longer allowed.