-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathslide-sample.html
More file actions
93 lines (90 loc) · 2.06 KB
/
slide-sample.html
File metadata and controls
93 lines (90 loc) · 2.06 KB
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
<!DOCTYPE HTML>
<html lang="ja">
<head>
<title>Slide Sample</title>
<meta charset="UTF-8">
<style>
* {
margin: 0;
padding: 0;
}
#content {
position: relative;
}
#wrapper {
position: relative;
margin: 100px auto;
width: 750px;
overflow: hidden;
}
ul {
width: 2500px;
transition: transform 0.25s ease-in;
}
li {
display: table-cell;
*display: inline;
width: 250px;
list-style: none;
}
#left-btn, #right-btn {
display: block;
position: absolute;
top: 140px;
color: red;
font-weight: bolder;
width: 60px;
height: 60px;
border-radius: 30px;
border: red 1px solid;
font-weight: 1.8em;
line-height: 60px;
text-align: center;
cursor: pointer;
z-index: 200;
}
#left-btn:hover, #right-btn:hover {
color: white;
background-color: red;
}
#left-btn {
left: 10px;
}
#right-btn {
right: 10px;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
</head>
<body>
<div id="content">
<div id="wrapper">
<span id="left-btn" data-calc="-250"><</span>
<ul id="slider" data-pos="0">
<li><img src="http://placekitten.com/g/250/380"></li>
<li><img src="http://placekitten.com/g/251/380"></li>
<li><img src="http://placekitten.com/g/252/380"></li>
<li><img src="http://placekitten.com/g/250/380"></li>
<li><img src="http://placekitten.com/g/250/380"></li>
<li><img src="http://placekitten.com/g/250/380"></li>
<li><img src="http://placekitten.com/g/250/380"></li>
<li><img src="http://placekitten.com/g/250/380"></li>
<li><img src="http://placekitten.com/g/250/380"></li>
<li><img src="http://placekitten.com/g/250/380"></li>
</ul>
<span id="right-btn" data-calc="250">></span>
</div>
</div>
<script type="text/javascript">
(function() {
$('#left-btn,#right-btn').on('click', function() {
var $this = $(this)
, $slider = $('#slider')
, dest = $slider.data('pos') + $this.data('calc');
$slider.css('transform', 'translate(' + dest + 'px, 0px)').on('transitionend', function() {
$slider.data('pos', dest)
});
});
})(jQuery);
</script>
</html>