用动画缓慢地从位置 A 移动到位置 B [英] Moving from position A to position B slowly with animation
本文介绍了用动画缓慢地从位置 A 移动到位置 B的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个使用 fadein
的简单 jQuery 动画,它可以工作,但一旦淡入...我希望使用 TOP 属性向上移动 30 像素,但速度很慢.
I have a simple jQuery animation using fadein
and it works but once faded in... I wish to MOVE using TOP property 30 pixels upwards, but slowly.
这是我目前所拥有的:
$('#Friends').fadeIn("slow");
我同时加载了 jQuery 和 jQuery UI...
I have both jQuery and jQuery UI loaded...
推荐答案
Use jquery animate 和给它一个很长的持续时间,比如 2000
Use jquery animate and give it a long duration say 2000
$("#Friends").animate({
top: "-=30px",
}, duration );
-= 表示动画将相对于当前的顶部位置.
The -= means that the animation will be relative to the current top position.
请注意,Friends
元素必须在 css 中将位置设置为相对:
Note that the Friends
element must have position set to relative in the css:
#Friends{position:relative;}
这篇关于用动画缓慢地从位置 A 移动到位置 B的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文