2012-02-13 7 views
0

Y a-t-il un moyen de redimensionner la fenêtre uniquement en proportion? Cela signifie que même si vous redimensionnez la fenêtre verticalement, l'horizontale sera également redimensionnée proportionnellement.Redimensionner la fenêtre en proportion

Je sais qu'un 'aspectRation' fait pour un div mais j'en ai besoin pour la fenêtre. S'il vous plaît voir l'exemple http://jqueryui.com/demos/resizable/aspect-ratio.html

Je voudrais redimensionner la fenêtre de cette façon Merci

Répondre

0

Merci Mate, Voici comment je l'ai fait travailler

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

vous devez écouter l'événement et faire les calibré calculs vous-même (en fonction de la taille précédente vs nouvelle taille). vous pourriez alors maintenir le rapport d'aspect désiré.

Questions connexes