Smooth Scrolling | CSS-Tricks - CSS-Tricks

PHOTO EMBED

Mon Apr 11 2022 11:13:00 GMT+0000 (Coordinated Universal Time)

Saved by @sharukhk08 #javascript

// Scroll to specific values
// scrollTo is the same
window.scroll({
  top: 2500, 
  left: 0, 
  behavior: 'smooth'
});

// Scroll certain amounts from current position 
window.scrollBy({ 
  top: 100, // could be negative value
  left: 0, 
  behavior: 'smooth' 
});

// Scroll to a certain element
document.querySelector('.hello').scrollIntoView({ 
  behavior: 'smooth' 
});
content_copyCOPY

https://css-tricks.com/snippets/jquery/smooth-scrolling/