Sunday, December 30, 2012

Enabling scrollbars for HTML Tables

Although most of you may know how to do this, it’s just a personal note for myself and for others who might get something out of it.

When you have a table with lots of rows/columns, it just spans out of the div or some other block and makes everything look horrible. The simplest solution is to have scrollbars to view items that fall outside the div and the simplest way to do it is by CSS.

The following CSS code makes the table occupy as much of the div containing it can, and then allows you to scroll along to view rest of the table.

#table-name{
overflow-x:scroll;
width:100%;
display:block;
}

Similarly, overflow-y:scroll can be used to set up a vertical scroller, but you’d also have to set the height to whatever size you want.


Source : thevoidghost[dot]wordpress[dot]com

0 comments:

Post a Comment