In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
Most people do not understand the knowledge points of this article "JavaScript how to achieve partial magnification of pictures on Taobao", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "JavaScript how to achieve local magnification of pictures on Taobao" article.
The results to be achieved are as follows:
Demo1 * {margin: 0; padding: 0;} .box {position: relative; width: 300px; height: 200px; background: url (". / JS cover .jpg"); / * set background image size * / background-size: 300px 200px } .slider {position: absolute; width: 100px; height: 100px; background: black; / * set transparency 0x1Power0 is fully transparent. * / opacity: 0.3;} .small {position: absolute; width: 100px; height:100px; background: url ('. / JS cover .jpg'); top: 0px; right:-300px; background-size: 300px 200px / * magnify the element, scale (3) means the width and height are magnified 3 times at the same time. * / transform: scale (3);} var slider = document.querySelector ('.slider'); var small = document.querySelector ('.small'); / / Mouse press slider.onmousedown = function (event) {var startX = event.offsetX; var startY = event.offsetY / / Mouse movement _ document.onmousemove = function (event1) {var l = event1.clientX-startX; var t = event1.clientY-startY; / / limit the small slider to the big slider if (l = 200) l = 200; if (t = 100) t = 100; slider.style.left = 1 + "px" Slider.style.top = t + "px"; / / modify the background image positioning of the small image small.style.backgroundPosition= "-" + 1 + "px -" + t + "px";}} / / when the mouse is raised, remove the mouse movement event _ document.onmouseup = function () {_ document.onmousemove = null;}
The running effect of the code:
The above is about the content of this article on "how to achieve partial magnification of pictures on Taobao by JavaScript". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more related knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.