Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

2
  • 7
    Pretty short and sweet. One thing to note - I think this only scrolls it into view (could be at the bottom of the viewport) rather than scrolling it to the top of the viewport, as setting scrollTop does.
    – OG Sean
    Commented Aug 4, 2019 at 2:19
  • I also used this solution, but at least Chrome version 92 for some reason has the smooth scrolling disabled by default, so this solution doesn't work anymore (as of writing this). Quite disappointing actually. It can still be enabled manually by selecting "Enabled" (instead of "Default") for the chrome://flags/#smooth-scrolling configuration. Commented Jul 31, 2021 at 4:45