I am encountering an issue on my webpage with a <div>
that contains a <table>
with rows of varying heights:
<html>
<head></head>
<body>
<div>
<table>
<tr>...
<tr>...
...
</table>
</div>
</body>
</html>
Currently, when the content in the table is long enough, the div extends beyond the bottom of the page viewport. I want to prevent the div from extending below the bottom of the page and instead add a scroll bar. I can easily add scroll bars if the div height is fixed using overflow: scroll
. However, I need the div height to adjust based on the user's browser window size.
Does anyone have any suggestions for achieving this? It is not necessary for the div to extend all the way to the bottom of the page if there is no table content. I would prefer a pure CSS solution rather than resorting to JavaScript to set the div height dynamically.
Thank you!