使用jquery animate()实现对文本的反弹效果?
16lz
2021-01-22
I am trying to use Jquery to create a bounce effect, this is what i have so far:
我试图使用Jquery创建一个反弹效果,这是我到目前为止:
Html:
HTML:
<div id ="animation">bounce</div>
Jquery:
jQuery的:
$("#animation").animate({ marginTop: "80px" }, 1500 )
.animate({ marginBottom: "40px" }, 800 );
Its goes downwards but not upwards, i tried searching the documentation, but it doesn't
它向下但不向上,我尝试搜索文档,但事实并非如此
working example here: http://jsfiddle.net/zLw8F/
这里的工作示例:http://jsfiddle.net/zLw8F/
3 个解决方案
#1
6
To go upwards again, you'd need to reduce the margin-top
instead of animating margin-bottom
:
要再次向上,你需要减少margin-top而不是动画margin-bottom:
$("#animation").animate({ marginTop: "80px" }, 1500 )
.animate({ marginTop: "40px" }, 800 );
Demo at jsfiddle.net
在jsfiddle.net上演示
Yet, to animate the element decoupled from the rest of the page, I recommend relative positioning instead of playing with margins.
然而,为了使与页面其余部分分离的元素动画,我建议相对定位而不是使用边距。
更多相关文章
- 行建立动画输入
- 【jQuery】调用delay()方法延时执行动画效果
- 如何停止基于CSS值的jquery动画?
- 具有嵌套效果循环的jquery动画
- day049--jQuery文档操作示例
- 怎么让CSS动画走的慢一点啊。
- 只对css类进行动画处理,没有显式样式
- ie8下jQuery动画没有ie7流畅,是浏览器性能问题吗?有没有什么解决方
- 动画滚动无法在Firefox中运行?