1

マウスでホバーすることで画像を拡大できるスクリプトの作成に誰かが私を導くことができるかどうか疑問に思っていましたが、画像が拡大されるだけでなく、画像の周りのdivも添付されて表示されますホバーすると

ありがとう!

4

1 に答える 1

4

最も簡単な方法。コードを resizables.js ファイルのどこかに配置します。

/**
 * Copyright 2012, Val Kotlarov Hoffman.
 * Licensed under the GPL Version 2 license.
 * You may copy freely and distribute as long as this comment remains.
 **/

$(document).ready(function(){ 
    init_resizeables();
});

function init_resizeables() {

    $('img').hover(
        function() { 
            $(this).stop().animate({
                'width':'444px'
            },{
                duration:234
            }).css({
                'z-index':'999', 
                'position':'absolute'
            });
        },
        function() { 
            $(this).stop().animate({
                'width':'254px'
            },{
                duration:345
            }).css({
                'z-index':'1'
            });
        });
}

最初のものは、ズームされた画像の幅です。2 番目の幅は、画像の通常のサイズです。これを html ファイルに含めるだけで完了です。imgセレクターを必要なものに変更します。楽しみ。

于 2012-04-20T12:33:05.360 に答える