-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgallery.html
88 lines (88 loc) · 2.75 KB
/
gallery.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<!DOCTYPE html>
<html>
<head>
<title>Gallery Demo</title>
<style>
html {
height: 100%;
}
body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}
#container {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: #ccc;
}
#gallery {
position: absolute;
top: 25%;
width: 60%;
left: 20%;
height: 50%;
border: 1px solid;
overflow: hidden;
}
.image {
position: absolute;
top: 0;
left: -100%;
width: 100%;
height: 100%;
overflow: hidden;
transition: left ease .8s;
}
.image img {
width: 100%;
height: 100%;
}
#image1 {
left: 0;
}
</style>
</head>
<body>
<div id="container">
<div id="gallery">
<div class="image" id="image1">
<img src="images/landing.jpg"/>
</div>
<div class="image" id="image2">
<img src="images/kanvas.jpg"/>
</div>
<div class="image" id="image3">
<img src="images/photography.jpg"/>
</div>
</div>
<button id="nextButton">Next</button>
<button id="previousButton">Previous</button>
</div>
<script type="text/javascript">
var current = 1;
var nextButton = document.getElementById('nextButton');
var previousButton = document.getElementById('previousButton');
nextButton.addEventListener('click', function() {
if (current == 3) {
return;
}
document.getElementById('image' + current).style.left = "100%";
current++;
document.getElementById('image' + current).style.left = "0%";
});
previousButton.addEventListener('click', function() {
if (current == 1) {
return;
}
document.getElementById('image' + current).style.left = "-100%";
current--;
document.getElementById('image' + current).style.left = "0%";
});
</script>
</body>
</html>