简体   繁体   English

使用鼠标悬停在另一个div中的图像上缩放图像

[英]Zoom an image with mouseover on image in another div

There is many plugins for zooming image (like jqzoom ). 有很多用于缩放图像的插件(例如jqzoom )。 But I want to zoom image with hovering on image in another div: 但是我想将图像悬停在另一个div中的图像上来缩放图像: 在此处输入图片说明

Is there any way to have an effect like jqzoom (inner zoom)but with mouseover on another element? 有什么办法可以产生像jqzoom(内部缩放)这样的效果,但是将鼠标悬停在另一个元素上吗? I want this effect : seavello.com/r/zoom/zoom.html, but with mouseover on thumbnial not main image Thanks in advance 我想要这种效果:seavello.com/r/zoom/zoom.html,但是将鼠标悬停在缩略图上而不是主图像

try this 尝试这个

$(document).ready(function(){
    $('img').hover(
        function () { 
            $(this).animate({width: '+=10', height: '+=10'}, 500);
        },
        function () {
            $(this).animate({width: '-=10', height: '-=10'}, 500);
    });
}); 

If the href is url for big image then: 如果href是大图片的网址,则:

var big = $('.main img');
$('.tumb').mouseover(function() {
   big.attr('src', $(this).attr('href'));
}).mouseout(function() {
   big.attr('src', '');
});

you can also preload images on start. 您也可以在开始时预加载图像。

var images = $.map($('.tumb'), function(item, index) {
   var img = new Image();
   img.src = item.attr('href');
   return img;
});

You can also add animations on hover. 您还可以在悬停时添加动画。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM