我有一个风格元素
position: relative; transition: all 2s ease 0s;
然后我想在点击它之后平滑地改变它的位置,但是当我添加样式改变时,转换不会发生,而是元素立即移动.
$$('.omre')[0].on('click',function(){ $$(this).style({top:'200px'}); });
但是,如果我更改color
属性,它会顺利更改.
$$('.omre')[0].on('click',function(){ $$(this).style({color:'red'}); });
可能是什么原因造成的?是否存在不属于"过渡性"的属性?
编辑:我想我应该提到这不是jQuery,它是另一个库.代码似乎按预期工作,样式正在添加,但转换仅适用于第二种情况?
也许你需要在你的CSS规则集来指定一个顶值,所以它会知道什么样的动画值从.
尝试在css中设置默认值(让它知道你想要从哪里开始)
position: relative; transition: all 2s ease 0s; top: 0; /* start out at position 0 */