민서네집

Scroll Bar의 size 구하기 / 좌우 Scroll Bar를 html 맨 밑으로 보내기 본문

WEB (HTML, CSS)

Scroll Bar의 size 구하기 / 좌우 Scroll Bar를 html 맨 밑으로 보내기

브라이언7 2016. 8. 30. 18:02

function getPageWidth() {

$('body, html').css('overflow', 'hidden');

window_width = $(window).width();

window_height = $(window).height();

$('body, html').css('overflow', 'auto');

}


function adjustSubmenu() {

// footer가 페이지의 맨 밑으로 가도록 contents의 높이를 조정한다.

// footer가 없더라도 Scroll Bar가 맨 밑으로 가게 하는 역할을 한다.

var height = $(window).height() - $("header").outerHeight() - $("footer").outerHeight()-$.scrollbarWidth();

$("#contents").css("min-height", height);

}


위 코드를  $(function () { ... }); 에서 한번 호출해주고, window resize 이벤트 핸들러 함수에도 넣어준다.


$(window).resize( function() {

getPageWidth();

adjustSubmenu();

});


Comments