The Jquery box zooms in with the area where the mouse is located _jquery

Source: Internet
Author: User
The effect of the following figure:

Implementation code: After running F5 refresh
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <ptml xmlns=" http://www.w3.org/1999/xhtml > <pead> <title>jquery box is enlarged with the mouse area </title& Gt <script src= "Http://img.jb51.net/jslib/jquery/jquery14.js" type= "Text/javascript" ></script> <style Type= "Text/css" > *{margin:0;padding:0;} . dock {Text-align:center;} . Dock div{width:8px;height:8px;border:1px #dfdfdf solid background: #dfdfdf; margin:2px auto; line-height:0px;o Verflow:hidden;} </style> </pead> <body> <div class= "Dock" ></div> <script language= "JavaScript" type= "Text/javascript" >//configuration var m=5;//max multiple var s=400;//distance center Max distance var count=20;//number//dock class function Dock () {This.dock Items=[]; This.additem=function (item) {This.dockItems.push ($ (item)); $ (item). Appendto (". Dock"); }; ///Generate Dock object instance var d=new dock (); Loop Insert Count Dockitem Dom object for (Var i=0;i<counti++) {d.additem (' <div class= ' +i+ ' "></div> '); }//Binding Dockitem function $ (". Dock div"). Bind ("MouseOver", function (event) {var w=$ (this). width (); var h=$ (this). Height (); var offset=$ (this). offset (); Onmouseitemout (Offset.top); }); Handling child Object Style function Onmouseitemout (top) {for (Var i=0;i<d.dockitems.length;i++) {var c=d.dockitems[i].attr (' class ') ; var of=$ ("." +c). offset (); D1=math.abs (Of.top-top); var z=zoomd (M,S,D1); $("." +c). css ({width:8*z+ "px", height:8*z+ "px"}); Compute magnification function ZOOMD (m,s,d) {var z=m* (s-d) * (s-d)/(s*s+1); Return (z<1) 1:z; } </script> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

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.