-
Notifications
You must be signed in to change notification settings - Fork 0
/
horizontalScroll.html
170 lines (143 loc) · 4.66 KB
/
horizontalScroll.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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
/* ==================== */
/* Set up styles */
/* ==================== */
html {
background-color: black;
}
.layermotion {
position: absolute;
white-space: nowrap;
font-size: 0;
}
.layer {
display: inline-block;
}
#layers {
position: relative;
overflow: hidden;
/* Viewport Width and Height */
width: 500px;
height: 500px;
}
/* =========================================== */
/* Define the animation for change in position */
/* =========================================== */
/* Left To Right: -50%, 0 then 0, 0 */
/* Right To Left: 0, 0 then -50%, 0 */
@keyframes scrollHoriz {
from { transform: translate( 0, 0 ); }
to { transform: translate( -50%, 0 ); }
}
@-webkit-keyframes scrollHoriz {
from { transform: translate( 0, 0 ); }
to { transform: translate( -50%, 0 ); }
}
@-ms-keyframes scrollHoriz {
from { transform: translate( 0, 0 ); }
to { transform: translate( -50%, 0 ); }
}
@-moz-keyframes scrollHoriz {
from { transform: translate( 0, 0 ); }
to { transform: translate( -50%, 0 ); }
}
/* ================================= */
/* Define the layer content and size */
/* ================================= */
/* BG Layer 0 */
.layermotion:nth-child(1) > .layer {
/* Layer image */
background-image: url(bg.png);
/* Layer Width and Height */
width: 500px;
height: 500px;
}
/* Layer 1 */
.layermotion:nth-child(2) > .layer {
/* Layer image */
background-image: url(layer-1.png);
/* Layer Width and Height */
width: 500px;
height: 500px;
}
/* Layer 2 */
.layermotion:nth-child(3) > .layer {
/* Layer image */
background-image: url(layer-2.png);
/* Layer Width and Height */
width: 500px;
height: 500px;
}
/* Layer 3 */
.layermotion:nth-child(4) > .layer {
/* Layer image */
background-image: url(layer-3.png);
/* Layer Width and Height */
width: 500px;
height: 500px;
}
/* ================================= */
/* Define the layer animation timing */
/* ================================= */
/* BG Layer 0 completes a scrollHoriz animation cycle in 20s */
.layermotion:nth-child(1){
animation: scrollHoriz 20s linear infinite;
-ms-animation: scrollHoriz 20s linear infinite;
-moz-animation: scrollHoriz 20s linear infinite;
-webkit-animation: scrollHoriz 20s linear infinite;
}
/* Layer 1 completes a scrollHoriz animation cycle in 15s */
.layermotion:nth-child(2){
/* scrollHoriz is the animation name */
/* 5s is the time for the animation to complete one loop */
animation: scrollHoriz 15s linear infinite;
-ms-animation: scrollHoriz 15s linear infinite;
-moz-animation: scrollHoriz 15s linear infinite;
-webkit-animation: scrollHoriz 15s linear infinite;
}
/* Layer 2 completes a scrollHoriz animation cycle in 10s */
.layermotion:nth-child(3){
/* scrollHoriz is the animation name */
/* 5s is the time for the animation to complete one loop */
animation: scrollHoriz 10s linear infinite;
-ms-animation: scrollHoriz 10s linear infinite;
-moz-animation: scrollHoriz 10s linear infinite;
-webkit-animation: scrollHoriz 10s linear infinite;
}
/* Layer 3 completes a scrollHoriz animation cycle in 5s */
.layermotion:nth-child(4){
/* scrollHoriz is the animation name */
/* 5s is the time for the animation to complete one loop */
animation: scrollHoriz 5s linear infinite;
-ms-animation: scrollHoriz 5s linear infinite;
-moz-animation: scrollHoriz 5s linear infinite;
-webkit-animation: scrollHoriz 5s linear infinite;
}
</style>
</head>
<body>
<div id="container">
<div id="layers">
<div class="layermotion">
<div class="layer" id="bg"></div>
<div class="layer" id="bg-dupe"></div>
</div>
<div class="layermotion">
<div class="layer" id="1"></div>
<div class="layer" id="1-dupe"></div>
</div>
<div class="layermotion">
<div class="layer" id="2"></div>
<div class="layer" id="2-dupe"></div>
</div>
<div class="layermotion">
<div class="layer" id="3"></div>
<div class="layer" id="3-dupe"></div>
</div>
</div>
</div>
</body>
</html>