参考: better way to center-zoom images?
可以查看上文中的演示代码或者代码:$('.pixbox img').on({
mouseover: function(){
var $scale = 1.5;
if (!$(this).data('w'))
{
$(this).data('w', $(this).width())
.data('h', $(this).height());
}
$(this).stop(true).animate({
width: $(this).data('w')*$scale,
height: $(this).data('h')*$scale,
left: -$(this).data('w')*($scale - 1)/2,
top: -$(this).data('h')*($scale - 1)/2
}, 'fast');
},
mouseout: function(){
$(this).stop(true).animate({
width: $(this).data('w'),
height: $(this).data('h'),
left: 0,
top: 0
}, 'fast');
}
});
可以查看上文中的演示代码或者代码:$('.pixbox img').on({
mouseover: function(){
var $scale = 1.5;
if (!$(this).data('w'))
{
$(this).data('w', $(this).width())
.data('h', $(this).height());
}
$(this).stop(true).animate({
width: $(this).data('w')*$scale,
height: $(this).data('h')*$scale,
left: -$(this).data('w')*($scale - 1)/2,
top: -$(this).data('h')*($scale - 1)/2
}, 'fast');
},
mouseout: function(){
$(this).stop(true).animate({
width: $(this).data('w'),
height: $(this).data('h'),
left: 0,
top: 0
}, 'fast');
}
});
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货