Software, your way.
burger menu icon
WillMaster

WillMaster > LibraryWeb Content Preparation

FREE! Coding tips, tricks, and treasures.

Possibilities weekly ezine

Get the weekly email website developers read:

 

Your email address

name@example.com
YES! Send Possibilities every week!

Horizontal Table Scroll (For Responsive Pages)

Some tables simply can't be made narrow enough to fit on a portrait-positioned phone, and still keep the text large enough to read.

A horizontal scrollbar can be implemented under the table when the table width exceeds the device width.

A technique to provide the scrollbar when needed is to put the table into a div containing the CSS overflow:auto; declaration. When the table is wider than the device, the div will provide horizontal scrolling.

This illustrates how to code it.

<div style="overflow:auto;">
   <table>
      [table content]
   </table>
</div>

With the CSS overflow:auto; declaration, the div will spawn a horizontal scroll bar whenever the table width exceeds the available width.

The following table is wider than the column and is horizontally scrollable.

One One One Two Two Two Three Three Three Four Four Four Five Five Five Six Six Six

This next table is narrower. On some phones, in portrait orientation, the table will be narrower than the screen. For those, the table can be scrolled horizontally.

One One One Two Two Two Three Three Three

To implement the functionality, put your table into a div with a CSS overflow:auto; declaration.

<div style="overflow:auto;">
[your table here]
</div>

When the table is wider than the available space, it's scrollable. Otherwise, not.

(This article first appeared with an issue of the Possibilities newsletter.)

Will Bontrager

Was this article helpful to you?
(anonymous form)

Support This Website

Some of our support is from people like you who see the value of all that's offered for FREE at this website.

"Yes, let me contribute."

Amount (USD):

Tap to Choose
Contribution
Method

All information in WillMaster Library articles is presented AS-IS.

We only suggest and recommend what we believe is of value. As remuneration for the time and research involved to provide quality links, we generally use affiliate links when we can. Whenever we link to something not our own, you should assume they are affiliate links or that we benefit in some way.

How Can We Help You? balloons
How Can We Help You?
bullet Custom Programming
bullet Ready-Made Software
bullet Technical Support
bullet Possibilities Newsletter
bullet Website "How-To" Info
bullet Useful Information List

© 1998-2001 William and Mari Bontrager
© 2001-2011 Bontrager Connection, LLC
© 2011-2024 Will Bontrager Software LLC