...

View Full Version : Looking to freeze table headers



dan18088
10-09-2003, 07:36 PM
Is there someway to freeze the header row of a table so if there are many rows you can still see the headers?

Thanks in advance,
Dan

me'
10-09-2003, 08:06 PM
Frames (http://www.w3schools.com/html/html_frames.asp).

Choopernickel
10-09-2003, 09:17 PM
Frames won't allow (without pixel-based positioning of cells, which should be avoided) the headers outside a scrolling area to line up with the columns inside the scrolling area.

Try something like this:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html>
<head>
<title>Scrolling Table Body</title>
<style type="text/css">
table.scroll {
height: 3em;
overflow: scroll;
}
table.scroll tbody {
height: 2em;
overflow: auto;
}
table.scroll tbody tr, table.scroll tbody td {
height: auto;
}
</style>
</head>
<body>
<table class="scroll">
<thead>
<tr>
<th>Header 1</th>
<th>Header 2</th>
<th>Header 3</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Footer 1</th>
<th>Footer 2</th>
<th>Footer 3</th>
</tr>
</tfoot>
<tbody>
<tr>
<td>Row 1, Cell 1</td>
<td>Row 1, Cell 2</td>
<td>Row 1, Cell 3</td>
</tr>
<tr>
<td>Row 2, Cell 1</td>
<td>Row 2, Cell 2</td>
<td>Row 2, Cell 3</td>
</tr>
<tr>
<td>Row 3, Cell 1</td>
<td>Row 3, Cell 2</td>
<td>Row 3, Cell 3</td>
</tr>
<tr>
<td>Row 4, Cell 1</td>
<td>Row 4, Cell 2</td>
<td>Row 4, Cell 3</td>
</tr>
</tbody>
</table>
</body>
</html>

It won't be very backward-compatible, but it should treat you just fine in modern browsers. A little testing proves my theory correct: it works in Firebird, and fails in IE 6.

Well, I'm sure there's some way.

dan18088
10-10-2003, 11:55 PM
Thanks, that did the trick!
Dan



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum