How can I smoothly scroll an element into view using JavaScript scroll into view? or What’s the best

18 Replies, 1245 Views

If you’re open to alternatives, you could use CSS for smooth scrolling instead!

Add this to your root element:
```css
html {
scroll-behavior: smooth;
}
```

Then just use regular anchor tags or `element.scrollIntoView()`. Works in most modern browsers and way simpler than JS hacks.

Downside? No IE support, but hey, who uses IE anymore? 😅

Messages In This Thread



Users browsing this thread: 1 Guest(s)