I am working on a basic HTML layout that contains a few elements, including a scrollable div container located below them.
Since the height of unknown-height
is uncertain due to dynamic element generation, I need a simple method to enable scrolling in the div container while ensuring its height does not exceed the bottom of the window.
.scrollbar {
overflow-y: auto;
overflow-x: hidden;
background-color: #FF0000;
overscroll-behavior-y: contain;
height: calc(100vh - 100px) !important;
}
<p id="unknown-height">
foo
</p>
<input type="text" />
<div class="scrollbar">
<p>Foo</p>
<!-- Add as many Foo paragraphs as needed -->
</div>