javascript放大镜效果问题
源代码如下:<body><imgsrc="./1.jpg"name="pic"width="350"><divid="box"style="width:350px;hei...
源代码如下:
<body> <img src="./1.jpg" name="pic" width="350"> <div id="box" style="width:350px;height:206px;display:none;"> </div> </body> <script type="text/javascript"> var image = document.pic; var box = document.getElementById("box"); image.onmousemove = function(event){ var ent = window.event||event; var mx = ent.clientX; var my = ent.clientY; var px = 4*mx - 175; var py = 4*my - 103; //console.log(px,py); box.style.display = "block"; //box.style.backgroundColor='lightblue'; box.style.background = "url(./1.jpg) -"+px+"px -"+py+"px no-repeat"; } </script> 展开
<body> <img src="./1.jpg" name="pic" width="350"> <div id="box" style="width:350px;height:206px;display:none;"> </div> </body> <script type="text/javascript"> var image = document.pic; var box = document.getElementById("box"); image.onmousemove = function(event){ var ent = window.event||event; var mx = ent.clientX; var my = ent.clientY; var px = 4*mx - 175; var py = 4*my - 103; //console.log(px,py); box.style.display = "block"; //box.style.backgroundColor='lightblue'; box.style.background = "url(./1.jpg) -"+px+"px -"+py+"px no-repeat"; } </script> 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询