I have a scrollable table in which I keep the headers visible as the table scrolls. The problem is that the border on the bottom of the tbody extends all the way to the end of the scrollbar. Since the scrollbar will hide when there is not enough data, this just leaves the border extending past the columns a few pixes.
How can I either make this border just as long as the columns in the tbody, or shrink when the scrollbar hides? I have tried moving the scroll to a div above the table, but this causes the headers to not freeze so I can't do that. I have also moved the border to different elements but they are all the same size. I can add whatever is needed to this html.
Another option would be to completely hide the bottom border if the table is not scrollable as there is a border at the bottom of the table already via the CSS.
<table id="driving" class="table2">
<thead style="display: block">
<tr>
<th scope="col" id="unit" class="sort">
<a href="#">Unit</a>
</th>
<th id="startDateTime" class="sort">
<a href="#">StartDate</a>
</th>
</tr>
</thead>
<tbody style="max-height: 450px; overflow-y: auto; border-bottom: 1px #ccc solid; display: block">
<tr>
<td>
@item.UnitNumber
</td>
<td class="center">
@item.StartDateTime.Date
</td>
</tr>
</tbody>
</table>