2014-03-19 67 views
-1
$(function(){ 
var navIsBig = true; 
var $nav = $('#header_nav'); 

$(document).scroll(function() { 
    var value = $(this).scrollTop(); 

    if (value > 50 && navIsBig){ 
     $nav.animate({height:45},"medium"); 
     $('.box').animate({height:36},"medium"); 
     $('.box').animate({width:78},"medium"); 
     navIsBig = false; 

    } 
    else if (value <= 50 && !navIsBig) { 
     $nav.animate({height:80},"medium"); 
     $('.box').animate({height:53},"medium"); 
     $('.box').animate({width:104},"medium"); 
     navIsBig = true; 
    } 
}); 
}); 

此處框縮小其大小,首先是它的高度,然後是它的寬度。但我想對角減小其尺寸...如何在向下滾動時對角減小框尺寸

http://jsfiddle.net/9fact/466/ 
+0

把高度和寬度一起想:http://jsfiddle.net/lshettyl/9fact/468 / – lshettyl

回答

2

能夠繪製兩個屬性:

DEMO jsFiddle

$('.box').animate({height:36, width:78});