HTML5模拟齿轮动画

这是一个基于HTML5的齿轮动画特效,我们将齿轮转动的物理学原理,转换为HTML5代码,在网页上实现了模拟齿轮转动的动画效果。该齿轮动画的最大特点是它由好多个齿轮组成,这对齿轮传动的算法要求就大大提高了,而且我们并没有用JavaScript,而是纯CSS3实现的。

在线演示   源码下载

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
< div  id = "level" >
< div  id = "content" >
< div  id = "gears" >
< div  id = "gears-static" >< font  size = "3" ></ font ></ div >
< div  id = "gear-system-1" >
< div  id = "shadow15"  class = "shadow" >< font  size = "3" ></ font ></ div >
< div  id = "gear15" >< font  size = "3" ></ font ></ div >
< div  id = "shadow14"  class = "shadow" >< font  size = "3" ></ font ></ div >
< div  id = "gear14" >< font  size = "3" ></ font ></ div >
< div  id = "shadow13"  class = "shadow" >< font  size = "3" ></ font ></ div >
< div  id = "gear13" >< font  size = "3" ></ font ></ div >
</ div >
< div  id = "gear-system-2" >
< div  id = "shadow10"  class = "shadow" >< font  size = "3" ></ font ></ div >
< div  id = "gear10" >< font  size = "3" ></ font ></ div >
< div  id = "shadow3"  class = "shadow" >< font  size = "3" ></ font ></ div >
< div  id = "gear3" >< font  size = "3" ></ font ></ div >
</ div >
< div  id = "gear-system-3" >
< div  id = "shadow9"  class = "shadow" >< font  size = "3" ></ font ></ div >
< div  id = "gear9" >< font  size = "3" ></ font ></ div >
< div  id = "shadow7"  class = "shadow" >< font  size = "3" ></ font ></ div >
< div  id = "gear7" >< font  size = "3" ></ font ></ div >
</ div >
< div  id = "gear-system-4" >
< div  id = "shadow6"  class = "shadow" >< font  size = "3" ></ font ></ div >
< div  id = "gear6" >< font  size = "3" ></ font ></ div >
< div  id = "gear4" >< font  size = "3" ></ font ></ div >
</ div >
< div  id = "gear-system-5" >
< div  id = "shadow12"  class = "shadow" >< font  size = "3" ></ font ></ div >
< div  id = "gear12" >< font  size = "3" ></ font ></ div >
< div  id = "shadow11"  class = "shadow" >< font  size = "3" ></ font ></ div >
< div  id = "gear11" >< font  size = "3" ></ font ></ div >
< div  id = "shadow8"  class = "shadow" >< font  size = "3" ></ font ></ div >
< div  id = "gear8" >< font  size = "3" ></ font ></ div >
</ div >
< div  id = "shadow1"  class = "shadow" >< font  size = "3" ></ font ></ div >
< div  id = "gear1" >< font  size = "3" ></ font ></ div >
< div  id = "gear-system-6" >
< div  id = "shadow5"  class = "shadow" >< font  size = "3" ></ font ></ div >
< div  id = "gear5" >< font  size = "3" ></ font ></ div >
< div  id = "gear2" >< font  size = "3" ></ font ></ div >
</ div >
< div  id = "shadowweight"  class = "shadow" >< font  size = "3" ></ font ></ div >
< div  id = "chain-circle" >< font  size = "3" ></ font ></ div >
< div  id = "chain" >< font  size = "3" ></ font ></ div >
< div  id = "weight" >< font  size = "3" ></ font ></ div >
</ div >
</ div >
</ div >

  css代码

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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
<font size= "3" ># level {
width : 100% ;
height : 1px ;
position : absolute ;
top : 50% ;
}
#content{
text-align : center ;
margin-top : -327px ;
}
#gears{
width : 478px ;
height : 655px ;
position : relative ;
display :inline- block ;
vertical-align : middle ;
}
#gears- static {
background : url (FgFnjks.png)  no-repeat  -363px  -903px ;
width : 329px ;
height : 602px ;
position : absolute ;
bottom : 5px ;
right : 0px ;
opacity: 0.4 ;
}
#title{
vertical-align : middle ;
color : #9EB7B5 ;
width : 43% ;
display :inline- block ;
}
#title h 1 {
font-family 'PTSansNarrowBold' sans-serif ;
font-size : 3.6em ;
text-shadow :rgba( 0 0 0 0.36 7px  7px  10px ;
}
#title p{
font-family sans-serif ;
font-size : 1.2em ;
line-height : 148% ;
text-shadow :rgba( 0 0 0 0.36 1px  1px  0px ;
}
.shadow{
-webkit-box-shadow:  4px  7px  25px  10px  rgba( 43 36 0 0.36 );
-moz-box-shadow:  4px  7px  25px  10px  rgba( 43 36 0 0.36 );
box-shadow:  4px  7px  25px  10px  rgba( 43 36 0 0.36 );
}
/*gear-system-1*/
#gear 15 {
background url (FgFnjks.png)  no-repeat  0  -993px ;
width 321px ;
height 321px ;
position : absolute ;
left : 45px ;
top : 179px ;
-webkit-animation: rotate-back  24000 ms linear infinite;
-moz-animation: rotate-back  24000 ms linear infinite;
-ms-animation: rotate-back  24000 ms linear infinite;
animation: rotate-back  24000 ms linear infinite;
}
#shadow 15 {
width : 306px ;
height : 306px ;
-webkit-border-radius: 153px ;
-moz-border-radius: 153px ;
border-radius: 153px ;
position : absolute ;
left : 52px ;
top : 186px ;
}
#gear 14 {
background url (FgFnjks.png)  no-repeat  0  -856px ;
width 87px ;
height 87px ;
position : absolute ;
left : 162px ;
top : 296px ;
}
#shadow 14 {
width : 70px ;
height : 70px ;
-webkit-border-radius: 35px ;
-moz-border-radius: 35px ;
border-radius: 35px ;
position : absolute ;
left : 171px ;
top : 304px ;
}
#gear 13 {
background url (FgFnjks.png)  no-repeat  0  -744px ;
width 62px ;
height 62px ;
position : absolute ;
left : 174px ;
top : 309px ;
-webkit-animation: rotate  8000 ms linear infinite;
-moz-animation: rotate  8000 ms linear infinite;
-ms-animation: rotate  8000 ms linear infinite;
animation: rotate  8000 ms linear infinite;
}
#shadow 13 {
width : 36px ;
height : 36px ;
-webkit-border-radius: 18px ;
-moz-border-radius: 18px ;
border-radius: 18px ;
position : absolute ;
left : 187px ;
top : 322px ;
}
/*gear-system-2*/
#gear 10 {
background url (FgFnjks.png)  no-repeat  0  -184px ;
width 122px ;
height 122px ;
position : absolute ;
left : 175px ;
top : 0 ;
-webkit-animation: rotate-back  8000 ms linear infinite;
-moz-animation: rotate-back  8000 ms linear infinite;
-ms-animation: rotate-back  8000 ms linear infinite;
animation: rotate-back  8000 ms linear infinite;
}
#shadow 10 {
width : 86px ;
height : 86px ;
-webkit-border-radius: 43px ;
-moz-border-radius: 43px ;
border-radius: 43px ;
position : absolute ;
left : 193px ;
top : 18px ;
}
#gear 3 {
background url (FgFnjks.png)  no-repeat  0  -1493px ;
width 85px ;
height 84px ;
position : absolute ;
left : 194px ;
top : 19px ;
-webkit-animation: rotate  10000 ms linear infinite;
-moz-animation: rotate  10000 ms linear infinite;
-ms-animation: rotate  10000 ms linear infinite;
animation: rotate  10000 ms linear infinite;
}
#shadow 3 {
width : 60px ;
height : 60px ;
-webkit-border-radius: 30px ;
-moz-border-radius: 30px ;
border-radius: 30px ;
position : absolute ;
left : 206px ;
top : 31px ;
}
/*gear-system-3*/
#gear 9 {
background url (FgFnjks.png)  no-repeat  -371px  -280px ;
width 234px ;
height 234px ;
position : absolute ;
left : 197px ;
top : 96px ;
-webkit-animation: rotate  12000 ms linear infinite;
-moz-animation: rotate  12000 ms linear infinite;
-ms-animation: rotate  12000 ms linear infinite;
animation: rotate  12000 ms linear infinite;
}
#shadow 9 {
width : 200px ;
height : 200px ;
-webkit-border-radius: 100px ;
-moz-border-radius: 100px ;
border-radius: 100px ;
position : absolute ;
left : 214px ;
top : 113px ;
}
#gear 7 {
background url (FgFnjks.png)  no-repeat  -371px  0 ;
width 108px ;
height 108px ;
position : absolute ;
left : 260px ;
top : 159px ;
-webkit-animation: rotate-back  10000 ms linear infinite;
-moz-animation: rotate-back  10000 ms linear infinite;
-ms-animation: rotate-back  10000 ms linear infinite;
animation: rotate-back  10000 ms linear infinite;
}
#shadow 7 {
width : 76px ;
height : 76px ;
-webkit-border-radius: 38px ;
-moz-border-radius:  38px ;
border-radius:  38px ;
position : absolute ;
left : 276px ;
top : 175px ;
}
/*gear-system-4*/
#gear 6 {
background url (FgFnjks.png)  no-repeat  0  -1931px ;
width 134px ;
height 134px ;
position : absolute ;
left : 305px ;
bottom : 212px ;
-webkit-animation: rotate-back  10000 ms linear infinite;
-moz-animation: rotate-back  10000 ms linear infinite;
-ms-animation: rotate-back  10000 ms linear infinite;
animation: rotate-back  10000 ms linear infinite;
}
#shadow 6 {
width : 98px ;
height : 98px ;
-webkit-border-radius: 49px ;
-moz-border-radius:  49px ;
border-radius:  49px ;
position : absolute ;
left : 323px ;
bottom : 230px ;
}
#gear 4 {
background url (FgFnjks.png)  no-repeat  0  -1627px ;
width 69px ;
height 69px ;
position : absolute ;
left : 337px ;
bottom : 245px ;
-webkit-animation: rotate-back  10000 ms linear infinite;
-moz-animation: rotate-back  10000 ms linear infinite;
-ms-animation: rotate-back  10000 ms linear infinite;
animation: rotate-back  10000 ms linear infinite;
}
/*gear-system-5*/
#gear 12 {
background url (FgFnjks.png)  no-repeat  0  -530px ;
width 164px ;
height 164px ;
position : absolute ;
left : 208px ;
bottom : 85px ;
-webkit-animation: rotate  8000 ms linear infinite;
-moz-animation: rotate  8000 ms linear infinite;
-ms-animation: rotate  8000 ms linear infinite;
animation: rotate  8000 ms linear infinite;
}
#shadow 12 {
width : 124px ;
height : 124px ;
-webkit-border-radius: 62px ;
-moz-border-radius: 62px ;
border-radius: 62px ;
position : absolute ;
left : 225px ;
bottom : 107px ;
}
#gear 11 {
background url (FgFnjks.png)  no-repeat  0  -356px ;
width 125px ;
height 124px ;
position : absolute ;
left : 228px ;
bottom : 105px ;
-webkit-animation: rotate-back  10000 ms linear infinite;
-moz-animation: rotate-back  10000 ms linear infinite;
-ms-animation: rotate-back  10000 ms linear infinite;
animation: rotate-back  10000 ms linear infinite;
}
#shadow 11 {
width : 88px ;
height : 88px ;
-webkit-border-radius: 44px ;
-moz-border-radius: 44px ;
border-radius: 44px ;
position : absolute ;
left : 247px ;
bottom : 123px ;
}
#gear 8 {
background url (FgFnjks.png)  no-repeat  -371px  -158px ;
width 72px ;
height 72px ;
position : absolute ;
left : 254px ;
bottom : 131px ;
-webkit-animation: rotate  6000 ms linear infinite;
-moz-animation: rotate  6000 ms linear infinite;
-ms-animation: rotate  6000 ms linear infinite;
animation: rotate  6000 ms linear infinite;
}
#shadow 8 {
width : 42px ;
height : 42px ;
-webkit-border-radius: 21px ;
-moz-border-radius:  21px ;
border-radius:  21px ;
position : absolute ;
left : 269px ;
bottom : 146px ;
}
/*gear1*/
#gear 1 {
background url (FgFnjks.png)  no-repeat  0  0 ;
width 135px ;
height 134px ;
position : absolute ;
left : 83px ;
bottom : 111px ;
-webkit-animation: rotate-back  10000 ms linear infinite;
-moz-animation: rotate-back  10000 ms linear infinite;
-ms-animation: rotate-back  10000 ms linear infinite;
animation: rotate-back  10000 ms linear infinite;
}
#shadow 1 {
width : 96px ;
height : 96px ;
-webkit-border-radius: 48px ;
-moz-border-radius: 48px ;
border-radius: 48px ;
position : absolute ;
left : 103px ;
bottom : 130px ;
}
/*gear-system-6*/
#gear 5 {
background url (FgFnjks.png)  no-repeat  0  -1746px ;
width 134px ;
height 135px ;
position : absolute ;
left : 22px ;
top : 108px ;
-webkit-animation: rotate  10000 ms linear infinite alternate;
-moz-animation: rotate  10000 ms linear infinite alternate;
-ms-animation: rotate  10000 ms linear infinite alternate;
animation: rotate  10000 ms linear infinite alternate;
}
#shadow 5 {
width : 96px ;
height : 96px ;
-webkit-border-radius: 48px ;
-moz-border-radius: 48px ;
border-radius: 48px ;
position : absolute ;
left : 41px ;
top : 127px ;
}
#gear 2 {
background url (FgFnjks.png)  no-repeat  0  -1364px ;
width 80px ;
height 79px ;
position : absolute ;
left : 49px ;
top : 136px ;
-webkit-animation: rotate-back  10000 ms linear infinite alternate;
-moz-animation: rotate-back  10000 ms linear infinite alternate;
-ms-animation: rotate-back  10000 ms linear infinite alternate;
animation: rotate-back  10000 ms linear infinite alternate;
}
/*weight*/
#weight{
background url (FgFnjks.png)  no-repeat  -371px  -564px ;
width 34px ;
height 92px ;
position : absolute ;
left : 1px ;
bottom : 0 ;
-webkit-animation: up  10000 ms linear infinite alternate;
-moz-animation: up  10000 ms linear infinite alternate;
-ms-animation: up  10000 ms linear infinite alternate;
animation: up  10000 ms linear infinite alternate;
}
#shadowweight{
width : 10px ;
height : 80px ;
position : absolute ;
left : 12px ;
bottom : 0px ;
-webkit-animation: up  10000 ms linear infinite alternate;
-moz-animation: up  10000 ms linear infinite alternate;
-ms-animation: up  10000 ms linear infinite alternate;
animation: up  10000 ms linear infinite alternate;
}
/*chain*/
#chain- circle {
background url (FgFnjks.png)  no-repeat  -371px  -706px ;
width : 146px ;
height : 147px ;
position : absolute ;
left : 17px ;
top : 102px ;
-webkit-animation: rotate  10000 ms linear infinite alternate;
-moz-animation: rotate  10000 ms linear infinite alternate;
-ms-animation: rotate  10000 ms linear infinite alternate;
animation: rotate  10000 ms linear infinite alternate;
}
#chain{
width : 1px ;
height : 380px ;
border-left : 2px  dotted  #C8D94A ;
position : absolute ;
left : 17px ;
top : 175px ;
opacity: 0.7 ;
-webkit-animation:  collapse  10000 ms linear infinite alternate;
-moz-animation:  collapse  10000 ms linear infinite alternate;
-ms-animation:  collapse  10000 ms linear infinite alternate;
animation:  collapse  10000 ms linear infinite alternate;
}
/*ANIMATIONS*/
/*rotate*/
@keyframes  "rotate"  {
from {
-webkit-transform: rotate( 0 deg);
-moz-transform: rotate( 0 deg);
-o-transform: rotate( 0 deg);
-ms-transform: rotate( 0 deg);
transform: rotate( 0 deg);
}
to {
-webkit-transform: rotate( 360 deg);
-moz-transform: rotate( 360 deg);
-o-transform: rotate( 360 deg);
-ms-transform: rotate( 360 deg);
transform: rotate( 360 deg);
}
}
@-moz-keyframes rotate {
from {
-moz-transform: rotate( 0 deg);
transform: rotate( 0 deg);
}
to {
-moz-transform: rotate( 360 deg);
transform: rotate( 360 deg);
}
}
@-webkit-keyframes  "rotate"  {
from {
-webkit-transform: rotate( 0 deg);
transform: rotate( 0 deg);
}
to {
-webkit-transform: rotate( 360 deg);
transform: rotate( 360 deg);
}
}
@-ms-keyframes  "rotate"  {
from {
-ms-transform: rotate( 0 deg);
transform: rotate( 0 deg);
}
to {
-ms-transform: rotate( 360 deg);
transform: rotate( 360 deg);
}
}
@-o-keyframes  "rotate"  {
from {
-o-transform: rotate( 0 deg);
transform: rotate( 0 deg);
}
to {
-o-transform: rotate( 360 deg);
transform: rotate( 360 deg);
}
}
/*rotate-back*/
@keyframes  "rotate-back"  {
from {
-webkit-transform: rotate( 0 deg);
-moz-transform: rotate( 0 deg);
-o-transform: rotate( 0 deg);
-ms-transform: rotate( 0 deg);
transform: rotate( 0 deg);
}
to {
-webkit-transform: rotate( -360 deg);
-moz-transform: rotate( -360 deg);
-o-transform: rotate( -360 deg);
-ms-transform: rotate( -360 deg);
transform: rotate( -360 deg);
}
}
@-moz-keyframes rotate-back {
from {
-moz-transform: rotate( 0 deg);
transform: rotate( 0 deg);
}
to {
-moz-transform: rotate( -360 deg);
transform: rotate( -360 deg);
}
}
@-webkit-keyframes  "rotate-back"  {
from {
-webkit-transform: rotate( 0 deg);
transform: rotate( 0 deg);
}
to {
-webkit-transform: rotate( -360 deg);
transform: rotate( -360 deg);
}
}
@-ms-keyframes  "rotate-back"  {
from {
-ms-transform: rotate( 0 deg);
transform: rotate( 0 deg);
}
to {
-ms-transform: rotate( -360 deg);
transform: rotate( -360 deg);
}
}
@-o-keyframes  "rotate-back"  {
from {
-o-transform: rotate( 0 deg);
transform: rotate( 0 deg);
}
to {
-o-transform: rotate( -360 deg);
transform: rotate( -360 deg);
}
}
/*weight up*/
@keyframes  "up"  {
from {
bottom 0px ;
}
to {
bottom 340px ;
}
}
@-moz-keyframes up {
from {
bottom 0px ;
}
to {
bottom 340px ;
}
}
@-webkit-keyframes  "up"  {
from {
bottom 0px ;
}
to {
bottom 340px ;
}
}
@-ms-keyframes  "up"  {
from {
bottom 0px ;
}
to {
bottom 340px ;
}
}
@-o-keyframes  "up"  {
from {
bottom 0px ;
}
to {
bottom 340px ;
}
}
/*chain up and down*/
@keyframes  "collapse"  {
from {
height 387px ;
}
to {
height 48px ;
}
}
@-moz-keyframes  collapse  {
from {
height 387px ;
}
to {
height 48px ;
}
}
@-webkit-keyframes  "collapse"  {
from {
height 387px ;
}
to {
height 48px ;
}
}
@-ms-keyframes  "collapse"  {
from {
height 387px ;
}
to {
height 48px ;
}
}
@-o-keyframes  "collapse"  {
from {
height 387px ;
}
to {
height 48px ;
}
}</font>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值