Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to freeze header row in HTML table?

I am using an HTML table and have applied vertical scroll to it and now I want to freeze the header row during scrolling. How can I do this?

like image 747
laxmi Avatar asked Jun 28 '11 05:06

laxmi


1 Answers

HTML:

<table>
 <tr id="header-row">
  <th>header col 1</th>
  <th>header col 2</th>
 </tr>
 <tr>
  <td>data</td>
  <td>data</td>
 <tr>
 <tr>...</tr>
 ...
</table>

CSS:

#header-row { position:fixed; top:0; left:0; }
table {padding-top:15px; }
like image 97
David Andersson Avatar answered Sep 28 '22 21:09

David Andersson