I'm using bootstrap 3 for a website project. I'm trying to create a page with a responsive table, so that I'd have the scrollbar when the table is too big. I made a test case like so:
<div class="row">
<h4>Nuværende kurser</h4>
<div class="col-12 col-sm-12 col-lg-12">
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>#</th>
<th>Table heading</th>
<th>Table heading</th>
<th>Table heading</th>
<th>Table heading</th>
<th>Table heading</th>
<th>Table heading</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
</tr>
<tr>
<td>2</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
</tr>
<tr>
<td>3</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
</tr>
</tbody>
</table>
</div>
</div><!-- end col-12 -->
</div><!-- end row -->
Now, the problem is that it doesn't add the scrollbar, it merely expands the website to the width of the table.
See a screenshot here:
I've seen it working on several other websites, so something I'm doing...is wrong.
For me it was the 'min-width' value in body element breaking the responsiveness of this class.
In my code, I did add a CSS class:
The layout did work for
sm
Try this
remove
<div class="table-responsive">...</div>
and move class table-responsive in
<div class="col-12 col-sm-12 col-lg-12">
example
<div class="col-12 col-sm-12 col-lg-12 table-responsive">
this 100% work but if dont work move class table-responsive to Earlier Div layer, In this case,
<div class="col-12 col-sm-12 col-lg-12">
must be removed.
I'v done it.
You will receive at xs-screen (example from my app):
I had this problem and found that it worked to either give the table a set width in px, or to set the table to display: block.
Replace your table-responsive with this