I AM EVERYTHING
[jQuery] 일정 높이만큼 스크롤시 fixed 본문
var gnbLoc = 570; // 스크롤 값
$(window).scroll(function() {
var winLoc = $(window).scrollTop();
if (winLoc > gnbLoc) {
$('.title').addClass('scroll');
$('.content').css('padding-top', '47px'); // title 높이 값
} else if (winLoc <= gnbLoc) {
headerLoc = (gnbLoc - winLoc); //37,36,35,34.....0,-1,-2...
$('.title').removeClass('scroll');
$('.content').css('padding-top', '0');
}
});
});
scroll이란 클래스에 position: fixed를 비롯해 변화되는 값 주기
'programming' 카테고리의 다른 글
[jQuery] li의 index값을 알아내어 탭 변경하기 (0) | 2018.09.13 |
---|---|
[jQuery] 스크롤 위 아래 감지하여 헤더 보이기 (0) | 2018.09.03 |
[jQuery] 체크박스 전체 체크, 해제하기 (0) | 2018.08.31 |
[jQuery] 체크박스 제어하기 (0) | 2018.08.31 |
[jQuery] 외부영역 클릭시 레이어 팝업 닫기 (0) | 2018.08.31 |
Comments