2010-06-03 97 views
0

我想動畫水平列表外觀。這是一個頂部導航欄。jQuery的動畫元素顯示 - 底部到頂部

以下工作相當不錯,但它從頂部(我假設爲ul)開始動畫到底部。

動畫底部會怎樣?

$("#topnavigation li").css({height:'0'}); // 'hide' it first 
$("#topnavigation li", this).stop().animate({height:'23px'},{queue:false,duration:1000}); 

回答

1

你必須調整它的位置以及..

$("#topnavigation li").css({height:'0', top:'23'}); // 'hide' it first 
$("#topnavigation li", this).stop().animate({height:'23px', top: '0px'},{queue:false,duration:1000}) 

;

當然,top的起始值可能會不同,這取決於您對元素的樣式。您可能會使用top或margin-top;取決於CSS。

您也可以在jqueryui中使用幻燈片效果,併爲隱藏和顯示指定上下方向。

+0

好東西,儘管我最後使用了marginTop,而不是頂部。 – 2010-06-14 12:36:50