0

こんにちは、スクリプトを使用してホバー時に画像を拡大していますが、左上から拡大し、中央からホバーする必要があり、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で「margin wxy z」が欲しいだけですが、それを取得できません:/誰も助けることができますか? ありがとうございました :)

4

1 に答える 1

1

画像が完全に配置されている場合は、これを行うことができますhttp://jsfiddle.net/8wGtp/

$('#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);
    }
});
于 2013-03-27T19:58:22.780 に答える