问题描述
<script type="text/javascript" src="./Scripts/jquery-1.5.1.min.js"></script>
<script type='text/javascript' >
$(document).ready(function () {
$("#start").animate({ left: "+=10px" }, 1000)
.animate({ left: "-5000px" }, 1000);
});
</script>
<p id="start">this is some text that i am going to animate </p>
关于这为什么没有动画,我正在绞尽脑汁.如果将left
更改为marginLeft
,它将按预期工作并进行动画处理.但是我不确定为什么left
没有.
I am racking my brain here as to why this doesn't animate. If I change left
to marginLeft
it will work as expected and animates. But i am not sure why left
doesn't.
有人可以解释吗?我看过许多其他脚本也做了类似的事情.
Can anyone explain please? I have seen many other scripts doing something similar.
推荐答案
要进行定位工作,您需要通过设置position
css属性来启用它.
For positioning to work, you need to have enabled it by setting the position
css property.
将其设置为fixed
或absolute
或relative
即可正常工作(取决于您要实现的目标)
Set it to fixed
or absolute
or relative
to work (depending on what you try to achieve)
引用 position
属性.
Quoting from the specs of the position
property.
和
这篇关于jQuery animate({left:& ++ 10& quot;})不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!