Join the Webstudio community

Updated last month

internal linking transition

At a glance

The community member is looking for a way to add a smooth transition when clicking on a link that leads to a section within the current page, as the current behavior is an abrupt "teleportation" to the section. The comments suggest two solutions:

scroll-behavior: smooth; can be added to the global CSS to make all links scroll smoothly to their sections. Alternatively, this can be defined on the global root element, which is considered a better approach than using a preset, as the latter may have undesired effects on client-side navigation.

The community members agree that defining the smooth scroll behavior on the global root is the better solution.

Does someone knows how to make a transition when clicking on a link that lead to a section in the current page ?
For now, when i click my link, it effectively jumps to the corresponding section but has absolutely no transition (it just "teleport" the view to the section where I want it to sliiide to the section)
J
K
B
5 comments
you can put this in an html embed
Plain Text
<style>
 * {
        /* Make links scroll to their sections smoothly. */
        scroll-behavior: smooth;
    }
</style>
it works like magic
thanks
Or it can be defined on global root. Btw we could even add it to root preset.
ah defining on global root is better way forsure

problem with preset, imo, is it might have undesired effects for some

cuz we use client side navigation, if i'm on bottom of contact page, and I click home link, it will navigate and scroll up at the same time. Kinda makes it unknown that a page was changed
You are right
Add a reply
Sign up and join the conversation on Discord