I'm creating a table in HTML and CSS that has its own scrollbars (as opposed to the page's scrollbars).
<div class = "results">
<table>
<thead>
<tr>
<th>Header</th>
<th>Header2</th>
<th>Header3</th>
<th>Header4</th>
</tr>
</thead>
<tbody>
<tr>
<td>Value1</td>
<td>Value2</td>
<td>Value3</td>
<td>Value4</td>
</tr>
</tbody>
</table>
</div>
body {
overflow: hidden;
}
.results {
overflow: auto;
height: 600px;
}
This achieves what I want but only on my screen. If I look at this table on another screen or resolution then the bottom scrollbar is in a different position. How do I make sure the bottom scrollbar is always at the bottom of the screen? I tried doing this with percentages instead and the bottom bar doesn't appear at all. I also tried doing vh instead of px but that just does the same thing. I can't seem to figure out how to make sure the bottom scrollbar will always be on the bottom of the screen. It seems I have to explicitly set the height in order for the table to have its own scrollbars.
I also tried setting the height to auto but that makes it so I can't scroll at all. It looks like the height has to be a specific value.
Using vh is a lot better than using px but the bottom bar still doesn't always appear at the bottom.