see jsbin
I have to make my html table vertically scrollable.
I have used below code on tbody
tag but its doesn't work for me
<tbody style="height: 100px; overflow: auto">
The approach of this article is to create table with 100% width using width property and create vertical scroll inside table body using overflow-y property. Overflow property is used to create scrollbar in table. Use display: block; property to display the block level element.
use overflow-y if you only want a vertical scroll bar and overflow if you want both a vertical and horizontal. Note: setting an overflow attribute to scroll will always display the scrollbars. If you want the horizontal/vertical scrollbars to only show up when needed, use auto .
Suppose we want to add a scroll bar option in HTML, use an “overflow” option and set it as auto-enabled for adding both horizontal and vertical scroll bars. If we want to add a vertical bar option in Html, add the line “overflow-y” in the files.
Just add the display:block to the thead > tr and tbody. check the below example
http://www.imaputz.com/cssStuff/bigFourVersion.html
Why don't you place your table in a div?
<div style="height:100px;overflow:auto;"> ... Your code goes here ... </div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With