-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
40 lines (35 loc) · 1.11 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Image Transition Site</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<div class="img-box">
<img src="images/transparent.png" width="100%">
<div class="img-wrap">
<img src="images/original.jpg" id="originalImg">
</div>
<span id="line">
<img src="images/arrow.png" class="arrow">
</span>
</div>
</div>
<script>
var ImgBox = document.querySelector(".img-box");
var ImgWrap = document.querySelector(".img-wrap");
var originalImg = document.getElementById("originalImg");
var line = document.getElementById("line");
originalImg.style.width = ImgBox.offsetWidth + "px";
var leftSpace = ImgBox.offsetLeft
ImgBox.onmousemove = function(e){
var boxWidth = (e.pageX - leftSpace) + "px";
ImgWrap.style.width = boxWidth;
line.style.left = boxWidth;
}
</script>
</body>
</html>