Utilizing Bootstrap 4, I have implemented a responsive table that I want to have a scrollable body. The table is structured as follows:
<div class="table-responsive">
<table class="table table-striped table-hover custom-table text-nowrap">
<thead>
<tr>
<th>row1</th>
<th>row2</th>
<th>row2</th>
</tr>
</thead>
<tbody>
<!-- some rows -->
</tbody>
</table>
To enable scrolling in the tbody, I applied a scss class .custom-table
to the table, like this:
.custom-table {
tbody {
height: 50px;
overflow-y: auto;
width: 100%;
display: block;
}
}
Unfortunately, the applied styling is not functioning as expected. The content in the tbody is shifting to the left. You can view the issue in this JSFiddle example. What could be causing this problem?