I've recently developed a handy jQuery plugin that perfectly suits your needs. It's compact in size and a breeze to set up.
All you need is a table with a thead and tbody sections.
You can enclose this table within a DIV element with a specific class, and the table will automatically adjust its size to fit inside that div. This means if your div resizes with the browser window, so will the table. The header remains fixed when scrolling, and you have the option to add a fixed footer as well. You even have the choice to replicate the header in the footer and keep it fixed. If the columns cannot all fit due to a small browser window, horizontal scrolling is enabled (including for the header).
This plugin also allows the browser to dynamically size the columns instead of having fixed widths.
To use the plugin, simply pass the classname of the DIV like this: $('.myDiv').fixedHeaderTable({footer: true, footerId: 'myFooterId'}); and let the plugin take care of the rest. The FooterID refers to an element on the page containing the footer markup, useful for pagination purposes.
If there are multiple tables on the page, the plugin can work for each one that requires a fixed header.
Take a look at the functionality here:
Please note that it's still in 'beta', and I continue to incorporate new features and address bugs regularly.
Supported browsers include IE6, IE7, IE8, FireFox, Safari, and Chrome.
For more information, you can also view my response to a similar query from another user: Frozen table header inside scrollable div