Smooth Scrolling
Code for smooth scrolling with JavaScript
November 17, 2021 •
Code 💻
1 min read
Very simple way to achieve smooth scrolling:
<a onClick="document.querySelector('.contact-form').scrollIntoView({ behavior: 'smooth' });">
</a>
Just by adding .scrollIntoView({ behavior: 'smooth' })
creates a smooth auto scroll to the element.