前言
分享一个笔者写过的js实现天猫淘宝购物放大镜效果的例子
正文
代码如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
*{
padding: 0;
margin: 0;
list-style: none;
border: none;
}
#box{
width: 400px;
height: 400px;
margin: 100px 0 0 100px;
position: relative;
}
#small_box{
width: 100%;
height: 100%;
border: 1px solid #CCCCCC;
box-sizing: border-box;
position: relative;
}
#small_box img{
width: 100%;
height: 100%;
}
#mask{
width: 100px;
height: 100px;
background-color:rgba(255,255,0 ,.4);
position: absolute;
left: 0;
top: 0;
cursor: move;
display: none;
}
#big_box{
width: 600px;
height: 600px;
border: 1px solid #CCCCCC;
position: absolute;
left: 410px;
top: 0;