我用jQuery写了这样一行代码: $('.shuffling').animate('left':500+'px')
想要实现一个图片向左移动的动画效果,但是页面上没有效果出现这是为什么呢
$(".shuffling").animate({height:"300px"});
括号里是对象形式
https://www.runoob.com/jquery/eff-animate.html
还有就是 向左 就得 控制marginLeft 你用 right 就必须配合 定位 了 需要给 元素设置 position 了
比如这个
https://www.runoob.com/try/try.php?filename=tryjquery_eff_ani_right
或者直接 marginLeft 就是这样
$('.shuffling').animate({ marginLeft: "500px" })
首先要明白 移动的动画的生成原理,移动的动画是需要参照物,比如参照物 body 对象 就需要设置这个 DIV 元素设定 初始位置和运动后的动画位置。另外 animate 方法参数是对象形式 你写法有错误!参考我写的
```javascript
<div class="shuffling" style="background:#F00; width:100px; height:100px; position:absolute; top:0px; left:0px;"></div>
<script>
$(function () {
$('.shuffling').animate({left:"300px"});
});
</script>
```