I've been working for a HTML/CSS fluid-width, fluid-height, fixed header table without success. I'm hoping you can point me to a JavaScript or jQuery solution.
Criteria:
- table must fill entire width of browser window (at least container)
- table must fill entire height of available container in browser window
- tbody must scroll y if there's not enough room for all rows
- thead th and tbody td columns must line up
Pure HTML/CSS is a bust. How about jQuery or JavaScript?
Here's a fiddle: http://jsfiddle.net/JXWfC/6/
Ultimately it will need to work on IE7+, and modern versions of Chrome and FireFox.
Here's some markup of my basic page:
<div class="container">
<div class="sidebar">
nav here
</div>
<div class="content">
<table>
<thead>
<tr><th>column 1</th><th>2</th><th>three</th><th>this is column four</th></tr>
</thead>
<tbody>
<tr><td>data</td><td>can</td><td>have</td><td>different widths: not all the same</td></tr>
<tr><td>table</td><td>-</td><td>should</td><td>fill 100% width and 100% height</td></tr>
<tr><td>and</td><td>-</td><td>should</td><td>not require all td's to be same width</td></tr>
<tr><td>but</td><td>-</td><td>percentage</td><td>% widths are just fine</td></tr>
<tr><td>and</td><td>if</td><td>there's</td><td>too many rows, it should scroll y (overflow-y: scroll)</td></tr>
<tr><td>sample</td><td>1</td><td>row</td><td>Lorem ipsum dolor sit amit.</td></tr>
<tr><td>sample</td><td>1</td><td>row</td><td>Lorem ipsum dolor sit amit.</td></tr>
<tr><td>sample</td><td>1</td><td>row</td><td>Lorem ipsum dolor sit amit.</td></tr>
<tr><td>sample</td><td>1</td><td>row</td><td>Lorem ipsum dolor sit amit.</td></tr>
</tbody>
</table>
</div>
</div>