forked from lingzuer/lingzuer.github.com
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcss3-loading.htm
More file actions
273 lines (257 loc) · 8.05 KB
/
Copy pathcss3-loading.htm
File metadata and controls
273 lines (257 loc) · 8.05 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
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
<!doctype html>
<html>
<head>
<title>CSS transform: CSS only loading spinners - Kilian Valkhof</title>
<link href="reset.css" rel="stylesheet" type="text/css">
<style>
/* general styling */
body {
width:450px;
margin:18px auto;
}
/* position the bars and balls correctly (rotate them and translate them outward)*/
.bar1 {
-moz-transform:rotate(0deg) translate(0, -40px);
-webkit-transform:rotate(0deg) translate(0, -40px);opacity:0.12;
}
.bar2 {
-moz-transform:rotate(45deg) translate(0, -40px);
-webkit-transform:rotate(45deg) translate(0, -40px);opacity:0.25;
}
.bar3 {
-moz-transform:rotate(90deg) translate(0, -40px);
-webkit-transform:rotate(90deg) translate(0, -40px);opacity:0.37;
}
.bar4 {
-moz-transform:rotate(135deg) translate(0, -40px);
-webkit-transform:rotate(135deg) translate(0, -40px);opacity:0.50;
}
.bar5 {
-moz-transform:rotate(180deg) translate(0, -40px);
-webkit-transform:rotate(180deg) translate(0, -40px);opacity:0.62;
}
.bar6 {
-moz-transform:rotate(225deg) translate(0, -40px);
-webkit-transform:rotate(225deg) translate(0, -40px);opacity:0.75;
}
.bar7 {
-moz-transform:rotate(270deg) translate(0, -40px);
-webkit-transform:rotate(270deg) translate(0, -40px);opacity:0.87;
}
.bar8 {
-moz-transform:rotate(315deg) translate(0, -40px);
-webkit-transform:rotate(315deg) translate(0, -40px);opacity:1;
}
/* set up the three bar spinners */
#div1, #div2,#div3 {
position:relative;
width:100px;
height:100px;
margin:25px;
-moz-border-radius:100px;
float:left;
-moz-transform:scale(0.5);
-webkit-transform:scale(0.5);
/* not used right now: */
-webkit-animation-name: rotateThis;
-webkit-animation-duration:2s;
-webkit-animation-iteration-count:infinite;
-webkit-animation-timing-function:linear;
}
#div1 div,
#div2 div,
#div3 div {
width:10px;
height:30px;
background:#000;
position:absolute;
top:35px;
left:45px;
}
/* shadows for the first spinner */
#div1 div {
-moz-box-shadow:black 0 0 4px;
-webkit-box-shadow:black 0 0 4px
}
/* rounded outer corners for the second */
#div2 div {
-moz-border-radius-topleft:10px;
-moz-border-radius-topright:10px;
-webkit-border-top-left-radius:10px;
-webkit-border-top-right-radius:10px;
}
/* full rounded corners and partially hidden for the third */
#div3 div {
-moz-border-radius:20px;
-webkit-border-radius:20px;
border-radius:20px;
}
#div3 .bar1,
#div3 .bar2,
#div3 .bar3 {opacity:0;}
/* set up the three ball spinners */
#div4, #div5, #div6 {
position:relative;
width:100px;
height:100px;
margin:25px;
-moz-border-radius:100px;
-webkit-border-radius:100px;
float:left;
-moz-transform:scale(0.5);
-webkit-transform:scale(0.5);
-webkit-animation-name: rotateThis;
-webkit-animation-duration:2s;
-webkit-animation-iteration-count:infinite;
-webkit-animation-timing-function:linear;
}
#div4 div,
#div5 div,
#div6 div {
width:20px;
height:20px;
background:#000;
-moz-border-radius:40px;
-webkit-border-radius:40px;
position:absolute;
left:40px;
top:40px;
}
/* add a shadow to the first */
#div4 div {
-moz-box-shadow:black 0 0 4px;
-webkit-box-shadow:black 0 0 4px;
}
/* increase the balls in size */
#div5 .bar1 {
-moz-transform:rotate(0deg) translate(0, -40px) scale(0.1);
-webkit-transform:rotate(0deg) translate(0, -40px) scale(0.1);opacity:0.12;}
#div5 .bar2 {
-moz-transform:rotate(45deg) translate(0, -40px) scale(0.2);
-webkit-transform:rotate(45deg) translate(0, -40px) scale(0.2);opacity:0.25;}
#div5 .bar3 {
-moz-transform:rotate(90deg) translate(0, -40px) scale(0.4);
-webkit-transform:rotate(90deg) translate(0, -40px) scale(0.4);opacity:0.37;}
#div5 .bar4 {
-moz-transform:rotate(135deg) translate(0, -40px) scale(0.6);
-webkit-transform:rotate(135deg) translate(0, -40px) scale(0.6);opacity:0.50;}
#div5 .bar5 {
-moz-transform:rotate(180deg) translate(0, -40px) scale(0.8);
-webkit-transform:rotate(180deg) translate(0, -40px) scale(0.8);opacity:0.62;}
#div5 .bar6 {
-moz-transform:rotate(225deg) translate(0, -40px) scale(1);
-webkit-transform:rotate(225deg) translate(0, -40px) scale(1);opacity:0.75;}
#div5 .bar7 {
-moz-transform:rotate(270deg) translate(0, -40px) scale(1.2);
-webkit-transform:rotate(270deg) translate(0, -40px) scale(1.2);opacity:0.87;}
#div5 .bar8 {
-moz-transform:rotate(315deg) translate(0, -40px) scale(1.4);
-webkit-transform:rotate(315deg) translate(0, -40px) scale(1.4);opacity:1;}
/* hide the last halve */
#div6 .bar1 ,
#div6 .bar2,
#div6 .bar3 {opacity:0;}
/* uncomment this to use css animation in webkit browsers */
/* @-webkit-keyframes rotateThis {
from {-webkit-transform:scale(0.5) rotate(0deg);}
to {-webkit-transform:scale(0.5) rotate(360deg);}
} */
</style>
<script>
//simple script to rotate all spinners 45 degrees on each tick
//this works differently from the css transforms, which is smooth
var count = 0;
function rotate() {
var elem = document.getElementById('div1');
var elem2 = document.getElementById('div2');
var elem3 = document.getElementById('div3');
var elem4 = document.getElementById('div4');
var elem5 = document.getElementById('div5');
var elem6 = document.getElementById('div6');
elem.style.MozTransform = 'scale(0.5) rotate('+count+'deg)';
elem2.style.MozTransform = 'scale(0.5) rotate('+count+'deg)';
elem3.style.MozTransform = 'scale(0.5) rotate('+count+'deg)';
elem4.style.MozTransform = 'scale(0.5) rotate('+count+'deg)';
elem5.style.MozTransform = 'scale(0.5) rotate('+count+'deg)';
elem6.style.MozTransform = 'scale(0.5) rotate('+count+'deg)';
elem.style.WebkitTransform = 'scale(0.5) rotate('+count+'deg)';
elem2.style.WebkitTransform = 'scale(0.5) rotate('+count+'deg)';
elem3.style.WebkitTransform = 'scale(0.5) rotate('+count+'deg)';
elem4.style.WebkitTransform = 'scale(0.5) rotate('+count+'deg)';
elem5.style.WebkitTransform = 'scale(0.5) rotate('+count+'deg)';
elem6.style.WebkitTransform = 'scale(0.5) rotate('+count+'deg)';
if (count==360) { count = 0 }
count+=45;
window.setTimeout(rotate, 100);
}
window.setTimeout(rotate, 100);
</script>
</head>
<body>
<h1>CSS only loading spinners</h1>
<p>This is a small experiment with the new CSS transforms in Firefox 3.5 and Webkit. — loading spinners using html, css and javascript. Tested in Firefox3.5 and Webkit. Feel free to use them. By <a href="http://kilianvalkhof.com">Kilian Valkhof</a>.</p>
<p>See the source code to enable css animations instead of javascript rotation.</p>
<h2>Bars:</h2>
<div id="div1">
<div class="bar1"></div>
<div class="bar2"></div>
<div class="bar3"></div>
<div class="bar4"></div>
<div class="bar5"></div>
<div class="bar6"></div>
<div class="bar7"></div>
<div class="bar8"></div>
</div>
<div id="div2">
<div class="bar1"></div>
<div class="bar2"></div>
<div class="bar3"></div>
<div class="bar4"></div>
<div class="bar5"></div>
<div class="bar6"></div>
<div class="bar7"></div>
<div class="bar8"></div>
</div>
<div id="div3">
<div class="bar1"></div>
<div class="bar2"></div>
<div class="bar3"></div>
<div class="bar4"></div>
<div class="bar5"></div>
<div class="bar6"></div>
<div class="bar7"></div>
<div class="bar8"></div>
</div>
<h2 style="clear:both">Balls:</h2>
<div id="div4">
<div class="bar1"></div>
<div class="bar2"></div>
<div class="bar3"></div>
<div class="bar4"></div>
<div class="bar5"></div>
<div class="bar6"></div>
<div class="bar7"></div>
<div class="bar8"></div>
</div>
<div id="div5">
<div class="bar1"></div>
<div class="bar2"></div>
<div class="bar3"></div>
<div class="bar4"></div>
<div class="bar5"></div>
<div class="bar6"></div>
<div class="bar7"></div>
<div class="bar8"></div>
</div>
<div id="div6">
<div class="bar1"></div>
<div class="bar2"></div>
<div class="bar3"></div>
<div class="bar4"></div>
<div class="bar5"></div>
<div class="bar6"></div>
<div class="bar7"></div>
<div class="bar8"></div>
</div>
<p>The blog post: <a href="http://kilianvalkhof.com/2010/css-xhtml/css3-loading-spinners-without-images/">CSS3 loading spinners without images</a>.</p>
</body>