【发布时间】:2013-11-26 02:33:30
【问题描述】:
所以我对 jQuery 还很陌生,我正在尝试制作漂浮在水中的冰山的连续动画。
这是水上的冰山..
我希望它有点旋转和摆动,这是我当前的循环动画代码.. 只需要一些帮助让它做我想做的事哈!
function iceburg() {
jQuery('.iceburg').css({bottom:0});
jQuery('.iceburg').animate ({
bottom: '10px'
}, 200, function() {
jQuery('.iceburg').animate ({
bottom: '0px'
}, 200);
});
}
iceburg();
我无法弄清楚我做错了什么以及如何旋转它?有人可以帮忙吗?
【问题讨论】:
-
同意@TCHdvlp 的优化评论。每次使用
jQuery('.iceburg')时,jQuery 都会遍历 DOM 以查找具有该类的每个元素。最好用那个 jQuery 对象创建一个变量,然后重新使用它。你会得到更好的表现!
标签: jquery css animation jquery-animate