【发布时间】:2011-08-03 09:23:54
【问题描述】:
我正在尝试为将鼠标悬停时宽度从 170 像素缩小到 150 像素的菜单元素设置动画。 我的问题是,默认的 .animate 收缩发生在我的矩形的右侧,我需要它在左侧收缩。我已经尝试过为左边距设置动画,但由于元素内有文本,所以在动画期间它会向右移动。
这是我正在使用的实际代码
$(document).ready(function(){
//When mouse rolls over
$("#navigation li").mouseover(function(){
$(this).stop().animate({marginLeft:'20'},{queue:false, duration:600, easing: 'easeOutBounce'})
});
//When mouse is removed
$("#navigation li").mouseout(function(){
$(this).stop().animate({marginLeft:'0'},{queue:false, duration:600, easing: 'easeOutBounce'})
});
});
我已经找到了一些其他的答案,但我不明白建议的解决方案。
【问题讨论】:
标签: jquery jquery-animate