![](https://i0.wp.com/media.dev.to/cdn-cgi/image/width=1000,height=500,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg1n3nf5mtvhjwfyhvej0.png?w=1200&ssl=1)
Conventional way
const hoge = hoge.getBoundingClientRect(); window.scrollTo({ left : hoge.left + window.pageXOffset, top: hoge.top + window.pageYOffset, behavior: 'smooth',
})
Recently way
hoge.scrollIntoView({behavior: "smooth"})
Viewport version
document.documentElement.clientHeight
Discover more from Coursity
Subscribe to get the latest posts sent to your email.