Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I keep the horizontal scroll bar visible in a responsive table?

I have a table with lots of rows, which results in a bootstrap "table-responsive" having the scroll bar off the bottom of the screen. To see the data that overflows to the sides you have to scroll to the bottom, move the scroll bar, then scroll back up again.

Have a look at this fiddle, http://jsfiddle.net/Lq4uk/1/

Here is the HTML code,

<div class="table-responsive">
<table class="table table-striped table-bordered">
<thead>
    <th>#</th>
    <th>Header 1</th>
    ... (bunch of headers)
</thead>
<tbody>
    <tr>
        <th>1</th>
        <th>Some long text to make this overflow</th>
        ... (bunch of cells)
    </tr>
    ... (lots more rows)
</tbody>
</table>

How can I make the horizontal scroll bar always visible?

Or, to look at it differently, how can I use the maximum amount of space available on the screen for the vertical size of the table?

like image 631
Duncan Drennan Avatar asked May 29 '14 13:05

Duncan Drennan


People also ask

How do I make my horizontal scroll bar always visible?

To show the scrollbars always on the webpage, use overflow: scroll Property. It will add both horizontal and vertical scrollbars to the webpage. To add only horizontal scrollbar use overflow-x: scroll property and for vertical scrollbar use overflow-y: scroll property.

How do I make my scrollbar visible all the time?

An alternative approach is to set the width of the html element to 100vw. On many if not most browsers, this negates the effect of scrollbars on the width. Save this answer. Show activity on this post.

How do I add a horizontal scrollbar to my bootstrap table?

Making all the div element in inline using display: inline-block; property. Adding the scroll bar to all the div element using overflow-x: auto; property. white-space: nowrap; property is used make all div in a single line.


1 Answers

In your CSS add these lines -

.table-responsive {
 height: 100vh;
 overflow: scroll;
 }
like image 78
Alimur Razi Rana Avatar answered Jan 05 '23 04:01

Alimur Razi Rana