Is there any way to theme an HTML table (CSS) with using the jQuery CSS themes?
All of my components look like they belong together except for my HTML table which looks different.
Is there any way to theme an HTML table (CSS) with using the jQuery CSS themes?
All of my components look like they belong together except for my HTML table which looks different.
Why noy just use the theme styles in the table? i.e.
And you don't need to use any code...
dochoffiday's answer is a great starting point, but for me it did not cut it (the CSS part needed a buff) so I made a modified version with several improvements.
See it in action, then come back for the description.
JavaScript
Differences with the original version:
ui-styled-table
(it sounds more consistent).live
call was replaced with the recommended.on
for jQuery 1.7 upwards.toggleClass
(a terser equivalent)first
on table cells has been removed.last-child
to the last table row is necessary to fix a visual glitch on Internet Explorer 7 and Internet Explorer 8; for browsers that support:last-child
it is not necessaryCSS
Notes
I have tested this on Internet Explorer 7 and upwards, Firefox 11 and Google Chrome 18 and confirmed that it works perfectly. I have not tested reasonably earlier versions of Firefox and Chrome or any version of Opera; however, those browsers are well-known for good CSS support and since we are not using any bleeding-edge functionality here I assume it will work just fine there as well.
If you are not interested in Internet Explorer 7 support there is one CSS attribute (introduced with the star hack) that can go.
If you are not interested in Internet Explorer 8 support either, the CSS and JavaScript related to adding and targeting the
last-child
CSS class can go as well.There are a bunch of resources out there:
Plugins with ThemeRoller support:
jqGrid
DataTables.net
UPDATE: Here is something I put together that will style the table:
The CSS: