상세 컨텐츠

본문 제목

jQuery animate를 이용한 자동 스크롤

Web

by mingoon.com 2021. 6. 1. 10:41

본문

반응형

특정 Element로 자동으로 스크롤하고 싶을 때

function scrollTo(selector) {
	$('html, body').animate({
		scrollTop: parseInt($( selector ).offset().top)
	}, 500);
}

동작하지 않는 경우, body에 아래 CSS를 추가해 본다.

height: auto; 
min-height: 100%;

 

댓글 영역