How To Make Html Table Vertically Scrollable
Solution 1:
Why don't you place your table in a div?
<divstyle="height:100px;overflow:auto;">
... Your code goes here ...
</div>
Solution 2:
Just add the display:block to the thead > tr and tbody. check the below example
http://www.imaputz.com/cssStuff/bigFourVersion.html
Solution 3:
Try this one.. It is working... Here JSBIN
tabletbody { height:300px; overflow-y:scroll; display:block; }
tablethead { display:block; }
Solution 4:
The best way to do this is strictly separate your table into two different tables - header and body:
<divclass="header"><table><tr><!-- th here --></tr></table></div><divclass="body"><table><tr><!-- td here --></tr></table></div>
.body {
height: 100px;
overflow: auto
}
If your table has a big width (more than screen width), then you have to add scroll events for horizontal scrolling header and body synchroniously.
You should never touch table tags (table, tbody, thead, tfoot, tr) with CSS properties display and overflow. Dealing with DIV wrappers is much more preferable.
Solution 5:
The jQuery plugin is probably the best option. http://farinspace.com/jquery-scrollable-table-plugin/
To fixing header you can check this post
Fixing Header of GridView or HtmlTable (there might be issue that this should work in IE only)
CSS for fixing header
div#gridPanel
{
width:900px;
overflow:scroll;
position:relative;
}
div#gridPanel th
{
top: expression(document.getElementById("gridPanel").scrollTop-2);
left:expression(parentNode.parentNode.parentNode.parentNode.scrollLeft);
position: relative;
z-index: 20;
}
<div height="200px"id="gridPanel" runat="server" scrollbars="Auto" width="100px">
table..
</div>
or
Very good post is here for this
How to Freeze Columns Using JavaScript and HTML.
or
No its not possible but you can make use of div and put table in div
<divstyle="height: 100px; overflow: auto"><tablestyle="height: 500px;">
...
</table></div>
Post a Comment for "How To Make Html Table Vertically Scrollable"