I'm working on a table that has a fixed first column and needs to be vertically scrollable. I'm almost there with my CSS code, but the table rows are not as wide as the columns and I'm unsure why this is happening.
.table th:first-child,
.table td:first-child {
position: sticky;
left: 0;
background-color: #ad6c80;
color: #373737;
}
table {
height: 300px;
}
tbody {
overflow-y: scroll;
height: 200px;
width: 100%;
position: absolute;
}
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="25474a4a51565157445565110b130b17">[email protected]</a>/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="https://unpkg.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c7a5a8a8b3b4b3b5a6b7eab3a6a5aba287f6e9f5f6e9f6">[email protected]</a>/dist/bootstrap-table.min.css">
</head>
<body>
<div class="container">
<table class="table table-bordered table-hover" data=toggle="table" data-search="true" data-show-columns="true">
<thead>
<tr>
<th scope='col' data-sortable="true">Column 1</th>
<th scope='col'>Column 2</th>
<th scope='col'>Column 3</th>
<th scope='col'>Column 4</th>
<th scope='col'>Column 5</th>
<th scope='col'>Column 6</th>
<th scope='col'>Column 7</th>
<th scope='col'>Column 8</th>
<th scope='col'>Column 9</th>
</tr>
</thead>
<tbody>
<tr>
<td>Conf</td>
<td>even 20 trail A</td>
<td>True</td>
<td>False</td>
<td>0</td>
<td>True</td>
<td>True</td>
<td>True</td>
<td>True</td>
</tr>
<tr>
<td>Conf</td>
<td>even 20 trail B</td>
<td>True</td>
<td>False</td>
<td>0</td>
<td>True</td>
<td>True</td>
<td>True</td>
<td>True</td>
</tr>
</tbody>
</table>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://unpkg.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="24464b4b50575056455409504546484164150a16150a15">[email protected]</a>/dist/bootstrap-table.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="bfdd
........
</body>
</html>