본문 바로가기
JavaScript, jQuery, Java

div 모니터 크기, 해상도에 맞추기(resize)

by 보리하늘 2017. 12. 20.
728x90
반응형

사용자의 모니터 크기나 해상도, 브라우저 크기에 따라

디자인 해놓은 요소의 위치나 크기가 변경된다.


이를 방지하기 위해 베이스가 되는 창이나 모니터의 크기를 구하여

배치시킨다.


브라우저 창 크기 : $(window).width(), $(window).height()

전체화면 크기 : ​screen.width, screen.height 




1
2
3
4
5
6
7
8
9
10
11
function leftOpen() {
    $('#timelinbx').css("width", $(window).width() - 280);
}
function leftClose() {
    $('#timelinbx').css("width""100%");
}
 
$(window).resize(function() {        
    $('.timelinbx').css('width', $(window).width() - 50 );        
    $('.timelinbx').css('height', $(window).height() - 50 );   
});
cs


728x90
반응형

댓글