The jquery control picture is gradually magnified by the center point _jquery

Source: Internet
Author: User

Sometimes we need to do a when the mouse placed in the picture, I hope the picture gradually become larger, that is, the picture width and height gradually become larger, but at this time, its left value and top value unchanged, it does not appear to be from the center point to scale. The following figure:


Zooming from a central point

The implementation code is as follows:

 <meta charset= "Utf-8" > <style type= "text/css" > #div1 {width:600px; height:40 0px; margin:50px Auto; position:relative; Text-align:center; 
padding-left:50px;} 
#div1 img{position:absolute; left:0 top:0; margin:0 Auto; </style> <div id= "Div1" >  </div> <scrip T type= "Text/javascript" src= "js/jquery-1.7.1.min.js" ></script> <script type= "Text/javascript" > $ ( 
Function () {$ (' #div1 img '). MouseEnter (function () {var wvalue=1.5 * $ (this). width (); 
var hvalue=1.5 * $ (this). Height (); $ (this). Animate ({width:wvalue, Height:hvalue, left: ("-" + (0.5 * $ (a). Width ())/2), Top: ("-" + (0.5 * $ (this). Height ()) 
/2)}, 1000); 
}. MouseLeave (function () {$ (this). Animate ({width: "m", Height: "1000", Left: "0px", Top: "0px"},); 
}); 
}); </script> 

The above is a small set to introduce the jquery control picture by the central point gradually magnified the relevant knowledge, hope to help everyone, if you want to know more content please pay attention to cloud Habitat community website!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.