代码:
Home > Web Front-end > JS Tutorial > body text

Jquery's ideas and code for realizing picture magnifying glass effect (self-written)_jquery

WBOY
Release: 2016-05-16 17:19:41
Original
1139 people have browsed it

There are a lot of restrictions on the Internet, and the documents are difficult to understand, and it is troublesome ~ I wrote one myself. Laughing

Algorithm:

Step 1:

The position of the enlarged picture = the width or height of the container where the mouse is located divided by the container itself Height and width, find the percentage of the mouse moving in the container

Part 2:

After getting the percentage

x=-(x percentage* The width of the image - the width of the display container/2);

y=-(y percentage * the height of the image - the height of the display container/2);

Two parameters, x and y , which is the position of the large picture. The size of the display container/2 is added at the end to ensure that the picture is displayed in the middle.

Rendering:
Jquery's ideas and code for realizing picture magnifying glass effect (self-written)_jquery
Code:

Copy code The code is as follows:




商品信息













Jquerys ideas and code for realizing picture magnifying glass effect (self-written)_jquery



Jquerys ideas and code for realizing picture magnifying glass effect (self-written)_jquery



























Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template