用JS實現購物網站商品放大鏡效果

分類:編程 時間:2017-02-11

放大鏡效果就是把鼠標移到圖片上的時候,旁邊會有另外一張大的圖片展示,放大鏡效果,那這樣的效果怎樣實現的呢,我把代碼發給大家,請大家參考。

<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <title>放大鏡</title>
 <style>
 *{margin:0;padding: 0;}
 #warp{width: 1184px;height:500px;margin:50px auto 0;background-color: #ccc;overflow: hidden;padding: 10px;position: relative;}
 #warp #minbox{width: 350px;height: 350px;float: left;position: relative;}
 #maxbox{width: 400px;height: 400px;position: absolute;left: 380px;overflow: hidden;display: none;}
 #maxbox img{width: 800px;height: 800px;position: absolute;}
 #con{float: left;margin-left: 20px;}
 #meng{width: 175px;height: 175px;position: absolute;background-color:yellow;opacity:0.4;filter:alpha(opacity=40);left: 0;top: 0;display: none;}
 </style>
</head>
<body>
 <div id="warp">
 <div id="minbox">
  <img src=http://www.bitscn.com/pdb/jsp/"images/min.jpg" alt="">