动画的marginLeft与jQuery [英] Animating marginLeft with jQuery

查看:257
本文介绍了动画的marginLeft与jQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法弄清楚动画marginLeft与jQuery的动画。我需要它减去938px每次用户点击链接,这是工作正常,当我使用 .css(),但我不知道如何使它与 .animate()

I can't figure out to animate marginLeft with jQuery. I need it to subtract 938px every time a user clicks on a link, which was working fine when I was using .css(), but I can't figure out how to make it work with .animate().

$("#full-wrapper #full").animate({
    marginLeft, -=938px
}, 500);

任何人都能知道为什么这不起作用?这是我的CSS版本:

Can anyone figure out why this doesn't work? This was my CSS version:

$("#full-wrapper #full").css("marginLeft","-=938px");

我使用CSS3作为动画,但需要使它在旧版浏览器中工作。

I was using CSS3 for animation, but need to make it work in older browsers.

推荐答案

代码中有一个语法错误,因为你在一个对象中传递参数 animate()您应该使用来分隔每个属性。试试这个:

There's a syntax error in your code, as you are passing parameters in an object to animate() you should use : not , to delimit each attribute. Try this:

$("#full-wrapper #full").animate({
    marginLeft: '-=938px'
}, 500);

示例fiddle

这篇关于动画的marginLeft与jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆