This repository has been archived by the owner on Oct 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathSlideshow.html
151 lines (132 loc) · 4.08 KB
/
Slideshow.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Slideshow</title>
<script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
<style>
.main-screen {
z-index: 98;
padding: 0;
height: 100%;
width: 100%;
}
.slideshow{
display: block;
width: 100%;
padding: 0;
margin: 0;
z-index: 99;
list-style: none;
}
.image {
position: absolute;
z-index: 0;
width: 100%;
height: 100%;
left: 0;
top: 0;
overflow: hidden;
display: block;
transition:opacity 1s ease-in-out;
-moz-transition:opacity 1s ease-in-out;
-webkit-transition:opacity 1s ease-in-out;
}
.image{
opacity: 0;
}
.active{
opacity: 1;
}
.nav-arrows a {
width: 42px;
height: 42px;
background: #fff;
position: absolute;
top: 51%;
left: 30px;
text-indent: -9000px;
cursor: pointer;
margin-top: -21px;
opacity: 0.9;
z-index: 99999;
}
.nav-arrows a:first-child{
left: auto;
right: 30px;
background-position: top right;
}
.nav-arrows a:hover {
opacity: 1;
}
</style>
</head>
<body>
<div id="nav-arrows" class="nav-arrows">
<a href="#" class="forward">Weiter</a>
<a href="#" class="backward">Zurück</a>
</div>
<div class="main-screen">
<ul class="slideshow">
<li class="image"><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/148866/bg-img.jpg"/></li>
<li class="image"><img src="https://d262ilb51hltx0.cloudfront.net/fit/t/1600/1280/gradv/29/81/55/1*wWCapE3Hmi4kN4Es33XUlQ.jpeg"/></li>
<li class="image"><img src="https://d262ilb51hltx0.cloudfront.net/fit/t/1600/1280/gradv/29/81/55/1*lvMMN_BQ0IZU2JWjzHfU7g.jpeg"/></li>
</ul>
</div>
<script>
$(document).ready(function() {
var time = 10000,
timer;
$('.slideshow li:first-child').addClass('active');
function play() {
timer = setInterval(function(){
var next = $(".slideshow .active").removeClass("active").next(".image");
if (!next.length) {
next = $(".slideshow .image:first");
}
next.addClass("active");
}, time);
}
play();
/*Start of function for next button */
function forward() {
$('.forward').click(function() {
clearInterval(timer);
play();
var go = $(".slideshow .active").removeClass("active").next(".image").addClass("active");
if (!go.length) {
go = $(".slideshow .image:first");
}
go.addClass("active");
});
}
forward();
/*Start of function for prev button */
function previous() {
$('.backward').click(function() {
clearInterval(timer);
play();
var go = $(".slideshow .active").removeClass("active").prev(".image").addClass("active");
if (!go.length) {
go = $(".slideshow .image:last");
}
go.addClass("active");
});
}
previous();
});
/*Blendet Weiter und Zurück button aus/ein */
var timer;
$(document).mousemove(function() {
if (timer) {
clearTimeout(timer);
timer = 0;
}
$('.backward, .forward').fadeIn();
timer = setTimeout(function() {
$('.backward, .forward').fadeOut()
}, 3000)
})
</script>
</body>
</html>