Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap responsive table doesn't scroll horizontally on iOS devices

I have a table with the following markup:

<div class="table-responsive"
    <table class="table table-hover"
        <!-- table data-->
    </table>
</div>

As the documentation says, my table should now be able to scroll horizontally. It does work if I use chrome's devices emulator. However, when I try it using a real iPhone (iPhone 5s in this case - tested on iPhone 6 as-well) then I can't scroll the table horizontally at all. I can see the last column displayed in the viewport by default and I just can't scroll it side ways. I tried that in chrome and safari on my iPhone and got the same behavior.

What I tried to do is add the -webkit-overflow-scroll: touch but it didn't solve the problem. I've also tried to manually add overflow-x: scroll instead of the default auto but no avail.

I'm not sure it matters but I also have a bootstrap plugin - offcanvas - by jasny bootstrap and I can't scroll that side menu vertically on my iPhone as-well. It all works in the emulators but fails on the real thing.

Maybe those two are connected somehow.

Any help is appreciated.

Edit:

I have just tested that on an android phone and it seems like I can scroll the table horizontally as expected. However, I still can't scroll the side menu vertically even on android. I guess it means that these problems aren't connected to each other.

like image 964
kfirba Avatar asked Nov 18 '15 06:11

kfirba


People also ask

How do I make my bootstrap table Mobile responsive?

You can make any table responsive across all viewports by wrapping a . table with . table-responsive class. Or, pick a maximum breakpoint with which to have a responsive table up to by using .

How do I make my table scrollable and responsive?

Create responsive tables by wrapping any . table in . table-responsive to make them scroll horizontally on small devices (under 768px). When viewing on anything larger than 768px wide, you will not see any difference in these tables.

Which bootstrap for class can be used to make a responsive table?

Use . table-responsive{-sm|-md|-lg|-xl} classes as needed to create responsive tables up to a particular breakpoint. From that breakpoint and up, the table will behave normally and not scroll horizontally.


1 Answers

I found out that by default the .table element has max-width: 100% and safari "respects" this so it set the width to be 100% which means that the .table element isn't overflowing the .table-responsive element hence causing it to not be scrollable. This somehow doesn't affect android phones.

The fix was rather easy:

.table-responsive .table {
    max-width: none;
}
like image 82
kfirba Avatar answered Sep 25 '22 13:09

kfirba