2011-10-28 29 views
0

http://jsfiddle.net/HLw9U/jQuery的動畫:有問題撤消固定股利

的動畫當文檔載入,頁腳滑梯頂端。

我想要它,所以當您單擊文檔時,頁腳滑回到底部。

但是,唉,它只是停留在頂部。

這裏發生了什麼詭計?

編輯:添加代碼

function slide_footer_to_top(){ 
    $j(".footer").animate({ 
     opacity: 0, 
     bottom: "20%", 
    }, 200, function(){ 
     // finished 
    }).animate({ 
     opacity: 1, 
     top: "0%", 
    }, 600, function(){ 
     // finished 
    }); 
} 

function slide_footer_to_bottom(){ 
    $j(".footer").animate({ 
     opacity: 0, 
     top: "inherit", 
     bottom: "100%", 
    }, 300, function(){ 
     // finished 
    }).animate({ 
     opacity: 1, 
     top: "inherit", 
     bottom: "0%", 
    }, 500, function(){ 
     // finished 
    }); 

回答

0

您設置的頂部和底部值在同一時間 - 前值覆蓋任何底值和DIV停留在頂端。嘗試是這樣的:

function slide_footer_to_bottom(){ 
    $j(".footer").animate({ 
     opacity: 0, 
     top: "90%", 
    }, 300, function(){ 
     // finished 
    }).animate({ 
     opacity: 1, 
     top: "90%", 
    }, 500, function(){ 
     // finished 
    }); 

或取消前值:

$j(".footer").css('top', '');