我正在尝试实现图像缩放效果(因为它位于具有溢出的容器中:隐藏,增加它的宽度并向左滑动应该可以解决这个问题。)
我设法让它增加宽度:
/* Zoom in images */
$('img.vectimg').load(function() {
$(this).data('width', this.width);
}).bind('mouseenter mouseleave', function(e) {
$(this).stop().animate({
width: $(this).data('width') * (e.type === 'mouseenter' ? 1.2 : 1)
});
});
但是如何添加动画以将其移动到左侧? 我尝试追加这个/但它没有用。
$(this).stop().animate({
left: $(this).position().left + 500
});
我是一个完整的新手,所以请不要带我努力:)
答案 0 :(得分:1)
您可以在同一个animate()
来电中添加多个属性。
$(this).stop().animate({
width: $(this).data('width') * (e.type === 'mouseenter' ? 1.2 : 1),
left: $(this).position().left + (e.type === 'mouseenter' ? 500 : -500)
});
答案 1 :(得分:1)