When using a sticky navbar in Webflow, smooth scrolling to page sections doesn’t account for the navbar's height, causing content to appear hidden beneath it. Here's how to manually adjust the scroll offset.
#about
).Option 1: Top Padding
Add top padding to each section equal to or slightly more than your navbar’s height.
Example: If your navbar is 80px tall, set padding-top: 80px on the section.
This prevents content from being hidden beneath the navbar.
Option 2: Negative Margin Inside Spacer Div
Place an empty spacer div at the top of each section.
Set its height to match the navbar height, then apply a negative margin-top equal to that height.
Example: Spacer div height = 80px, margin-top = -80px.
If sections have dynamic content or the navbar height changes (e.g., responsive layouts or shrinking navs), use JavaScript for scroll offset compensation.
Embed a custom script in the Page Settings > Before
tag:
Scroll with offset using scrollIntoView({ behavior: 'smooth' })
and modify the Y-position using window.scrollTo()
.
This requires assigning custom click handlers to your nav links.
If using this method, disable Webflow’s default smooth scroll:
Go to Project Settings > Custom Code > Footer Code and add:
Webflow.push(function() { $('a[href*="#"]').off('click'); });
Note: Exact JavaScript implementation depends on your structure. If you want a plug-and-play script, Webflow doesn’t provide one, so custom coding is necessary.
To fix content being hidden behind a sticky navbar, use top padding on sections equal to the navbar height or insert a spacer div with negative margin at the top of each section. For dynamic navbar heights, consider using custom JavaScript to apply scroll offsets manually.