jQuery的动画元素显示 - 底部到顶部
问题描述:
我想动画水平列表外观。这是一个顶部导航栏。jQuery的动画元素显示 - 底部到顶部
以下工作相当不错,但它从顶部(我假设为ul)开始动画到底部。
动画底部会怎样?
$("#topnavigation li").css({height:'0'}); // 'hide' it first
$("#topnavigation li", this).stop().animate({height:'23px'},{queue:false,duration:1000});
答
你必须调整它的位置以及..
$("#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中使用幻灯片效果,并为隐藏和显示指定上下方向。
好东西,尽管我最后使用了marginTop,而不是顶部。 – 2010-06-14 12:36:50