2012-02-13 4 views
0

비율에 따라 창의 크기를 조정할 수있는 방법이 있습니까? 윈도우를 세로로 리사이즈 한 경우에도 수평으로 비율이 조정됩니다.비율로 창 크기 조정

저는 'aspectRation'은 div에 대해 알고 있지만 창에는 필요합니다. 예를 http://jqueryui.com/demos/resizable/aspect-ratio.html

나는이 방법을 창에게 당신이 onsize 이벤트를 수신하고 계산을 직접 할 필요가 감사

답변

0

덕분에 , 메이트 이것은 내가 그것을

imgRow = 8; 
imgCol = 6; 

max_w = $(window).width()/imgRow 
max_w = $(window).width()/imgCol 

if(max_w > 147) max_w = 147;//Not to exceed its original width 
if(max_h > 147) max_h = 147;//Not to exceed its original height 

$("img").each(function(i) { 
    var this_w=$(this).height(); 
    var this_h=$(this).width(); 
    if (this_w/this_h < max_w/max_h) { 
    var h = max_h; 
    var w = Math.ceil(max_h/this_h * this_w); 
    } else { 
    var w = max_w; 
    var h = Math.ceil(max_w/this_w * this_h); 
    } 
    $(this).css({ height: h, width: w }); 
}); 
작동하게하는 방법이다
0

의 크기를 조정하고 싶은 참조하십시오 (새 크기 대 이전의 크기에 따라). 원하는 가로 세로 비율을 유지할 수 있습니다.