I am designing a table using adaptive bootstrap. So far, no less. columns, that was good. With a fixed header, everything worked fine.
JSFIDDLE VERTICAL CLIP
Now it took me more than 20 columns in the table, and it should also be able to scroll horizontally.
JSFIDDLE HORIZONTAL SCROLLBAR
I tried to get them to work together, for a fixed title table for vertical and horizontal scrolling with the ability to scroll the title.
I tried this:
.table-fixed thead {
width: 97%;
}
.table-fixed tbody {
height: 150px;
overflow-y: auto;
width: 100%;
}
.table-fixed thead,
.table-fixed tbody,
.table-fixed tr,
.table-fixed td,
.table-fixed th {
display: block;
}
.table-fixed tbody td,
.table-fixed thead>tr>th {
float: left;
border-bottom-width: 0;
}
.table-fixed thead {
width: 97%;
}
.table-fixed tbody {
height: 230px;
overflow-y: auto;
width: 100%;
}
.table-fixed thead,
.table-fixed tbody,
.table-fixed tr,
.table-fixed td,
.table-fixed th {
display: block;
}
.table-fixed tbody td,
.table-fixed thead>tr>th {
float: left;
border-bottom-width: 0;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="container">
<div class="row">
<div class="panel panel-default table-responsive">
<table class="table table-fixed">
<thead>
<tr>
<th class="col-xs-1">S.No.</th>
<th class="col-xs-1">Name</th>
<th class="col-xs-1">Balance</th>
<th class="col-xs-1">Action</th>
<th class="col-xs-1">S.No.</th>
<th class="col-xs-1">Name</th>
<th class="col-xs-1">Balance</th>
<th class="col-xs-1">Action</th>
<th class="col-xs-1">S.No.</th>
<th class="col-xs-1">Name</th>
<th class="col-xs-1">Balance</th>
<th class="col-xs-1">Action</th>
</tr>
</thead>
<tbody>
<tr>
<td class="col-xs-1">1</td>
<td class="col-xs-1">Mike Adams</td>
<td class="col-xs-1">100000000000000</td>
<td class="col-xs-1">ewed</td>
<td class="col-xs-1">1</td>
<td class="col-xs-1">Mike Adams</td>
<td class="col-xs-1">100000000000000</td>
<td class="col-xs-1">ewed</td>
<td class="col-xs-1">1</td>
<td class="col-xs-1">Mike Adams</td>
<td class="col-xs-1">100000000000000</td>
<td class="col-xs-1">ewed</td>
</tr>
<tr>
<td class="col-xs-1">1</td>
<td class="col-xs-1">Mike Adams</td>
<td class="col-xs-1">100000000000000</td>
<td class="col-xs-1">ewed</td>
<td class="col-xs-1">1</td>
<td class="col-xs-1">Mike Adams</td>
<td class="col-xs-1">100000000000000</td>
<td class="col-xs-1">ewed</td>
<td class="col-xs-1">1</td>
<td class="col-xs-1">Mike Adams</td>
<td class="col-xs-1">100000000000000</td>
<td class="col-xs-1">ewed</td>
</tr>
<tr>
<td class="col-xs-1">1</td>
<td class="col-xs-1">Mike Adams</td>
<td class="col-xs-1">100000000000000</td>
<td class="col-xs-1">ewed</td>
<td class="col-xs-1">1</td>
<td class="col-xs-1">Mike Adams</td>
<td class="col-xs-1">100000000000000</td>
<td class="col-xs-1">ewed</td>
<td class="col-xs-1">1</td>
<td class="col-xs-1">Mike Adams</td>
<td class="col-xs-1">100000000000000</td>
<td class="col-xs-1">ewed</td>
</tr>
<tr>
<td class="col-xs-1">1</td>
<td class="col-xs-1">Mike Adams</td>
<td class="col-xs-1">100000000000000</td>
<td class="col-xs-1">ewed</td>
<td class="col-xs-1">1</td>
<td class="col-xs-1">Mike Adams</td>
<td class="col-xs-1">100000000000000</td>
<td class="col-xs-1">ewed</td>
<td class="col-xs-1">1</td>
<td class="col-xs-1">Mike Adams</td>
<td class="col-xs-1">100000000000000</td>
<td class="col-xs-1">ewed</td>
</tr>
<tr>
<td class="col-xs-1">1</td>
<td class="col-xs-1">Mike Adams</td>
<td class="col-xs-1">100000000000000</td>
<td class="col-xs-1">ewed</td>
<td class="col-xs-1">1</td>
<td class="col-xs-1">Mike Adams</td>
<td class="col-xs-1">100000000000000</td>
<td class="col-xs-1">ewed</td>
<td class="col-xs-1">1</td>
<td class="col-xs-1">Mike Adams</td>
<td class="col-xs-1">100000000000000</td>
<td class="col-xs-1">ewed</td>
</tr>
<tr>
<td class="col-xs-1">1</td>
<td class="col-xs-1">Mike Adams</td>
<td class="col-xs-1">100000000000000</td>
<td class="col-xs-1">ewed</td>
<td class="col-xs-1">1</td>
<td class="col-xs-1">Mike Adams</td>
<td class="col-xs-1">100000000000000</td>
<td class="col-xs-1">ewed</td>
<td class="col-xs-1">1</td>
<td class="col-xs-1">Mike Adams</td>
<td class="col-xs-1">100000000000000</td>
<td class="col-xs-1">ewed</td>
</tr>
<tr>
<td class="col-xs-1">1</td>
<td class="col-xs-1">Mike Adams</td>
<td class="col-xs-1">100000000000000</td>
<td class="col-xs-1">ewed</td>
<td class="col-xs-1">1</td>
<td class="col-xs-1">Mike Adams</td>
<td class="col-xs-1">100000000000000</td>
<td class="col-xs-1">ewed</td>
<td class="col-xs-1">1</td>
<td class="col-xs-1">Mike Adams</td>
<td class="col-xs-1">100000000000000</td>
<td class="col-xs-1">ewed</td>
</tr>
<tr>
<td class="col-xs-1">1</td>
<td class="col-xs-1">Mike Adams</td>
<td class="col-xs-1">100000000000000</td>
<td class="col-xs-1">ewed</td>
<td class="col-xs-1">1</td>
<td class="col-xs-1">Mike Adams</td>
<td class="col-xs-1">100000000000000</td>
<td class="col-xs-1">ewed</td>
<td class="col-xs-1">1</td>
<td class="col-xs-1">Mike Adams</td>
<td class="col-xs-1">100000000000000</td>
<td class="col-xs-1">ewed</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
Run codeHide resultI just added repeating rows so the table could scroll. How to make a table with the ability to scroll vertically (with a fixed title) and horizontally (with a scrollable title)?