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
Top comments (0)