Enlarging images when mouseover using Jquery?

后端 未结 4 1722
耶瑟儿~
耶瑟儿~ 2021-01-06 04:46

I am trying to enlarge the images when mouseover and reduce the size back to normal after mouseout. I have the following:

$(\'#image img\').live(\"mouseover\         


        
相关标签:
4条回答
  • 2021-01-06 05:34

    Try this: http://jsfiddle.net/FPKAP/11/ or using hover: http://jsfiddle.net/FPKAP/12/

    When you will hover over the HULK it will zoomin and on mouse out zoom out.

    This should help the need, lemme know if I misunderstood anything please, :)

    code

    $('#zoomimg').mouseenter(function() {
        $(this).css("cursor","pointer");
        $(this).animate({width: "50%", height: "50%"}, 'slow');
    });
    
    $('#zoomimg').mouseleave(function() {   
        $(this).animate({width: "28%"}, 'slow');
    });
    

    code

    $('#zoomimg').hover(function() {
        $(this).css("cursor", "pointer");
        $(this).animate({
            width: "50%",
            height: "50%"
        }, 'slow');
    
    }, function() {
        $(this).animate({
            width: "28%"
        }, 'slow');
    
    });​
    
    0 讨论(0)
  • 2021-01-06 05:40

    Increasing the width and height of the image , changes the position of the image (ie) it is enlarged but not in the same position where the original image was present.

    Using Scaling property will address this issue.

    .transition {
        -webkit-transform: scale(2); 
        -moz-transform: scale(2);
        -o-transform: scale(2);
        transform: scale(2);
    }
    

    Fiddle link : http://jsfiddle.net/RC7kb/178/

    0 讨论(0)
  • 2021-01-06 05:40

    You can use this: jsFiddle

    $('#image').hover(function(){
        $(this).css({width:"100%",height:"100%"});
    },function(){
        $(this).css({width:"50%",height:"50%"});   
    });
    
    0 讨论(0)
  • 2021-01-06 05:48

    I'd first try CSS for this:

    #image img {
      width: 50%;
      height: 50%;
    }
    
    #image img:hover {
      width: 100%;
      height: 100%;
    }
    
    0 讨论(0)
提交回复
热议问题