|
@@ -0,0 +1,73 @@
|
|
|
|
|
+<!DOCTYPE html>
|
|
|
|
|
+<html lang="en">
|
|
|
|
|
+<head>
|
|
|
|
|
+ <meta charset="UTF-8">
|
|
|
|
|
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
|
+ <title>Document</title>
|
|
|
|
|
+ <style>
|
|
|
|
|
+ body{
|
|
|
|
|
+ margin: 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ .small-img{
|
|
|
|
|
+ width: 400px;
|
|
|
|
|
+ height: 400px;
|
|
|
|
|
+ background-image: url("./img/niu.png");
|
|
|
|
|
+ background-size: 400px 400px;
|
|
|
|
|
+ position: relative;
|
|
|
|
|
+ float: left;
|
|
|
|
|
+ }
|
|
|
|
|
+ .bg{
|
|
|
|
|
+ width: 200px;
|
|
|
|
|
+ height: 200px;
|
|
|
|
|
+ background-color: rgba(255,255,255,0.6);
|
|
|
|
|
+ position: absolute;
|
|
|
|
|
+ }
|
|
|
|
|
+ .big-img{
|
|
|
|
|
+ width: 400px;
|
|
|
|
|
+ height: 400px;
|
|
|
|
|
+ background-image: url("./img/niu.png");
|
|
|
|
|
+ float: left;
|
|
|
|
|
+ margin-left: 30px;
|
|
|
|
|
+ background-size: 800px 800px;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ </style>
|
|
|
|
|
+</head>
|
|
|
|
|
+<body>
|
|
|
|
|
+ <div class="small-img">
|
|
|
|
|
+ <div class="bg"></div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div class="big-img">
|
|
|
|
|
+
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <script>
|
|
|
|
|
+ var oBg = document.getElementsByClassName("bg")[0];
|
|
|
|
|
+ var oSmallImg = document.getElementsByClassName("small-img")[0];
|
|
|
|
|
+ var oBigImg = document.getElementsByClassName("big-img")[0];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ oSmallImg.onmousemove = function(event){
|
|
|
|
|
+ var x = event.clientX - 100;
|
|
|
|
|
+ var y = event.clientY - 100;
|
|
|
|
|
+
|
|
|
|
|
+ if(y<=0){
|
|
|
|
|
+ y = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ if(x<=0){
|
|
|
|
|
+ x = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ if(y>=200){
|
|
|
|
|
+ y = 200;
|
|
|
|
|
+ }
|
|
|
|
|
+ if(x >= 200){
|
|
|
|
|
+ x = 200;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ oBg.style.top = y + "px";
|
|
|
|
|
+ oBg.style.left = x + "px";
|
|
|
|
|
+ oBigImg.style.backgroundPosition = (-2*x)+"px " + (-2*y) +"px";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ </script>
|
|
|
|
|
+</body>
|
|
|
|
|
+</html>
|