-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcarousel1.html
151 lines (130 loc) · 3.21 KB
/
carousel1.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
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Shiny Image Carousel</title>
<link href='https://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'>
<style>
html,
body {
margin: 0;
padding: 0;
}
body {
background-color: #e3e3e3;
color: #a1a1a1;
font: 16px/1.3em 'Roboto', sans-serif;
}
.container {
margin-left: auto;
margin-right: auto;
padding: 16px;
max-width: 1124px;
}
.slider {
margin: 1px auto;
position: relative;
width: 100%;
}
.slider img {
display: block;
max-width: 100%;
}
.slider h3 {
color: #656565;
font-size: 14px;
margin-bottom: 0.5em;
text-shadow: 1px 1px 0 rgba(255,255,255,0.8);
}
.slider p {
font-size: 11px;
margin: 0.5em;
text-shadow: 1px 1px 0 rgba(255,255,255,0.9);
}
.item {
cursor: pointer;
left: 50%;
margin-left: -33.333%;
position: absolute;
text-align: center;
transform-origin: top;
transition: transform 0.6s ease;
width: 66.667%;
}
.item-img {
position: relative;
}
.item-img:after {
background: rgba(0,0,0,0.2);
content: "";
height: 100%;
left: 0;
position: absolute;
top: 0;
transition: opacity 0.3s ease;
width: 100%;
}
.active .item-img:after {
opacity: 0;
}
.before {
transform: scale(0.5) translate(-100%, 42px);
}
.after {
transform: scale(0.5) translate(100%, 42px);
}
.active {
transform: scale(1);
z-index: 1;
}
</style>
</head>
<body>
<div class="container">
<div class="slider">
<div class="item before">
<div class="item-img">
<img src="http://placehold.it/750x250?text=one" alt="" />
</div>
<h3>Heading</h3>
<p>Lorem ipsum dolor sit amet.</p>
</div>
<div class="item active">
<div class="item-img">
<img src="http://placehold.it/750x250?text=two" alt="" />
</div>
<h3>Heading</h3>
<p>Lorem ipsum dolor sit amet.</p>
</div>
<div class="item after">
<div class="item-img">
<img src="http://placehold.it/750x250?text=three" alt="" />
</div>
<h3>Heading</h3>
<p>Lorem ipsum dolor sit amet.</p>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script>
$('.item').click(function(){
var $this = $(this),
$active = $('.active');
$after = $('.after');
$before = $('.before');
if($this.hasClass('active')){
return;
}
if($this.hasClass('before')){
$after.removeClass('after').addClass('before');
$active.removeClass('active').addClass('after');
}
else if($this.hasClass('after')){
$before.removeClass('before').addClass('after');
$active.removeClass('active').addClass('before');
}
$this.removeClass('before after').addClass('active');
});
</script>
</body>
</html>