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.

然而,为了使与页面其余部分分离的元素动画,我建议相对定位而不是使用边距。

更多相关文章

  1. 行建立动画输入
  2. 【jQuery】调用delay()方法延时执行动画效果
  3. 如何停止基于CSS值的jquery动画?
  4. 具有嵌套效果循环的jquery动画
  5. day049--jQuery文档操作示例
  6. 怎么让CSS动画走的慢一点啊。
  7. 只对css类进行动画处理,没有显式样式
  8. ie8下jQuery动画没有ie7流畅,是浏览器性能问题吗?有没有什么解决方
  9. 动画滚动无法在Firefox中运行?

随机推荐

  1. ActionBar的自定义样式
  2. android语音搜索结果显示页实现
  3. Android用ViewPager实现多页面的切换效果
  4. 系出名门Android(4) - 活动(Activity),
  5. listview常用的优化技巧
  6. Android序列化
  7. android开发步骤简要笔记
  8. 同步、更新、下载Android Source & SDK f
  9. Android的核心服务 2
  10. Eclipse Android project name有错误, sou