I have a large table of data which is often much higher than the available screen height. What I am trying to achieve is to put the table in a fixed-height div and when the user scrolls down, all the data rows scroll but the single top row of headings stays where it is, ie always visible at the top.
Obviously I can put the table in a div and specify CSS like:
This allows the user to scroll through the table independently of the page, which is fine. But obviously the headings disappear as soon as they do that.
I tried putting the div just around the data rows, ie:
but it didn't seem to work.
I also tried specifying <thead>, <tfoot> and <tbody> sections and applying the CSS to the <tbody> section but this didn't work either.
Does anyone know if what I'm trying to achieve is even possible, and if so how to do it?
--James
Obviously I can put the table in a div and specify CSS like:
Code:
div {
width: 100%;
height: 400px;
overflow: auto;
}
This allows the user to scroll through the table independently of the page, which is fine. But obviously the headings disappear as soon as they do that.
I tried putting the div just around the data rows, ie:
Code:
<table>
<tr>
<td>Head 1</td>
<td>Head 2</td>
<td>Head 3</td>
</tr>
<div>
<tr>
<td>Data 1</td>
<td>Data 2</td>
<td>Data 3</td>
</tr>
...
</div>
</table>
but it didn't seem to work.
I also tried specifying <thead>, <tfoot> and <tbody> sections and applying the CSS to the <tbody> section but this didn't work either.
Does anyone know if what I'm trying to achieve is even possible, and if so how to do it?
--James