I would like to create a full height webpage with a sticky header. The remainder of the page below the header is used for content. This content div itself should not have scroll, but I still want to have scrollable divs inside of it.
Some example HTML to show case the structure of what I want to achieve:
<div class="full-height-page">
<-- sticks to the top -->
<header class="sticky-header">
HEADER
</header>
<-- fills the remainder of the height and has no scroll -->
<main class="main-content">
<div class="two-cols-wrapper">
<-- this should scroll! -->
<div class="col-1">
<!-- overflowing content -->
</div>
<-- this should scroll! -->
<div class="col-2">
<!-- overflowing content -->
</div>
</div>
</div>
</div>
A non-working example using Tailwind CSS
What is the best way to go about this? I see solutions that set a fixed height, but I want my height to be set dynamically.
I expected setting scroll-y would work as is, but it does not.
You'd want to apply
height: 100%viah-fullto the<div>child of the<main>element, so that theheightis "passed" down to the column scrollable elements. Furthermore,flex-shrink: 0viashrink-0should be applied to each of the column content elements to avoid them shrinking to fit. You'd want to avoid them shrinking to fit so that the scrolling is evident.