Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jquery图像缩放_Javascript_Jquery - Fatal编程技术网

Javascript jquery图像缩放

Javascript jquery图像缩放,javascript,jquery,Javascript,Jquery,您好,我正在使用一个脚本放大悬停时的图像,但是它从左上角放大,我需要它从中间悬停,我不知道如何将css添加到jquery中以添加负边距,所以它按照我希望的方式进行,这是脚本 $('#sun').width(); $('#sun').mouseover(function(){ $(this).css("cursor","pointer"); $(this).animate({width: "7%"}, 'slow'); }); $('#sun').mouseout(function

您好,我正在使用一个脚本放大悬停时的图像,但是它从左上角放大,我需要它从中间悬停,我不知道如何将css添加到jquery中以添加负边距,所以它按照我希望的方式进行,这是脚本

$('#sun').width();
$('#sun').mouseover(function(){
    $(this).css("cursor","pointer");
    $(this).animate({width: "7%"}, 'slow');
});
$('#sun').mouseout(function(){
    $(this).animate({width: "6%"}, 'slow');
});

我只想要css中的“边距w x y z”,但无法获得它:/有人能帮忙吗?谢谢:)

如果图像完全定位,您可以这样做


要设置负边距的动画还是只添加它?设置动画时,它将显示为从图像的中心而不是左上角放大。谢谢。你只需要CSS3就可以做到这一点。将容器设置为一半大小,图像设置为100%宽度,悬停时添加缩放变换和过渡。是的,我知道,但它必须是jquery…或flash builder,但我不想使用POS-“-讨厌flash builder hahaThanks这是我需要的,是的,它们绝对定位,再次感谢!)
$('#resize').on({
    mouseenter: function(){
        $(this).animate({width: '130px', height: '130px', top: '-=15px', left: '-=15px'}, 500);
    },
    mouseleave: function(){
        $(this).animate({width: '100px', height: '100px', top: '+=15px', left: '+=15px'}, 500);
    }
});