To center a section in the middle of the screen on in-page link click in Webflow, you need to offset the browser’s default scroll behavior. By default, browsers align the target element to the top of the viewport.
#contact
).#contact
).Webflow does not offer native scroll centering, but you can simulate it using scroll-margin-top with custom CSS:
Add a custom embed component (from the Add Panel), or go to Page Settings > Custom Code > Inside Head tag, and paste:
``
This offsets the section so it scrolls into the center of the viewport (40vh = 40% of viewport height from the top; adjust as needed).
40vh
) and set it to display flex
with justify: center
and align: center
to center content. But this method affects layout permanently, not just on scroll.To center a section in the viewport on in-page navigation in Webflow, assign it an ID and apply a scroll-margin-top using custom code. This ensures the section scrolls into a centered position without layout changes.