Scroll the preview
Watch the header shrink smoothly as you scroll past the threshold.
Build a header that shrinks smoothly as the page scrolls. Scroll the preview, tune the heights, then copy the code.
Scroll inside this box to watch the header shrink smoothly.
Keep scrolling to see the effect settle in.
This mimics a real page header on a long content page.
More content down here so there's room to scroll.
And a little more to make sure it scrolls nicely.
Watch the header shrink smoothly as you scroll past the threshold.
Choose the normal and shrunk header heights to fit your design.
Get a small scroll listener plus the matching CSS transition.
A scroll listener checks the container's scrollTop against a threshold and toggles a "scrolled" class, which a CSS transition animates smoothly between heights.
position: sticky keeps the header within its normal document flow until it reaches the top of its scroll container, avoiding some of the layout quirks fixed positioning can introduce.
Yes, enable the shadow option to fade in a drop shadow once the page has scrolled past the threshold, which helps separate the header from content beneath it.