Help! I can't seem to get the footer of my scrollable block element to stay at the bottom. It only sticks if the content (in this case, a table) is taller than the container itself. How can I ensure that the footer always stays at the bottom?
I attempted using position: absolute
, but that causes the footer to remain fixed when the user scrolls.
.container {
position: relative;
overflow-y: scroll;
height: 150px;
display: block;
border: solid 1px black;
}
.footer {
position: sticky;
right: 0;
bottom: 0;
float: right;
background-color: lightblue;
}
<div class="container">
<table>
<tr><td>Hello</td></tr>
<tr><td>Hello</td></tr>
// Additional table rows...
</table>
<div class="footer">Footer</div>
</div>