0
我想要的是一個動畫的div,它將在300px和100%的窗口高度減去26 px之間切換高度。我面臨的問題是,在窗口調整大小後,div不會更新它的擴展大小。我總是希望它擴展到windowheight-26px,但現在它只能切換到第一個窗口高度,它不會更新。我現在所擁有的代碼是:jQuery更新切換功能的變量,在窗口調整大小
$j(document).ready(function(){
var $nh = $j(window).height()-26;
$j("#header-wrap").toggle(function(){
toggleHeaderDown($nh);
},function(){
toggleHeaderUp();
});
function toggleHeaderDown(y){
$j("#header-wrap").animate({height:y},400,'easeInOutQuart');
$j("#header-image").animate({height:'100%'},400,'easeInOutQuart');
$j("#head1, #head2, #head3, #head4").animate({top: 0},400,'easeInOutQuart');
};
function toggleHeaderUp(){
$j("#header-wrap, #header-image").animate({height:300},400,'easeInOutQuart');
$j("#head1").animate({top: -50},400,'easeInOutQuart');
$j("#head2").animate({top: -370},400,'easeInOutQuart');
$j("#head3").animate({top: -200},400,'easeInOutQuart');
$j("#head4").animate({top: -330},400,'easeInOutQuart')
};});
$j(window).resize(function() {
$nh = $j(window).height()-26;
});
啊當然,我是多麼的愚蠢啊!非常感謝,它做到了 – 2012-04-02 06:40:12