基于HTML5的齿轮动画特效

我们从自然手上收到的最大礼物就是生命。我必须拼命的奔跑我知道有很多人等着看我狼狈跌倒的下场嘲笑我不自量力

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

HTML代码

XML/HTML Code复制内容到剪贴板
  1. <divid="level">
  2. <divid="content">
  3. <divid="gears">
  4. <divid="gears-static"></div>
  5. <divid="gear-system-1">
  6. <divclass="shadow"id="shadow15"></div>
  7. <divid="gear15"></div>
  8. <divclass="shadow"id="shadow14"></div>
  9. <divid="gear14"></div>
  10. <divclass="shadow"id="shadow13"></div>
  11. <divid="gear13"></div>
  12. </div>
  13. <divid="gear-system-2">
  14. <divclass="shadow"id="shadow10"></div>
  15. <divid="gear10"></div>
  16. <divclass="shadow"id="shadow3"></div>
  17. <divid="gear3"></div>
  18. </div>
  19. <divid="gear-system-3">
  20. <divclass="shadow"id="shadow9"></div>
  21. <divid="gear9"></div>
  22. <divclass="shadow"id="shadow7"></div>
  23. <divid="gear7"></div>
  24. </div>
  25. <divid="gear-system-4">
  26. <divclass="shadow"id="shadow6"></div>
  27. <divid="gear6"></div>
  28. <divid="gear4"></div>
  29. </div>
  30. <divid="gear-system-5">
  31. <divclass="shadow"id="shadow12"></div>
  32. <divid="gear12"></div>
  33. <divclass="shadow"id="shadow11"></div>
  34. <divid="gear11"></div>
  35. <divclass="shadow"id="shadow8"></div>
  36. <divid="gear8"></div>
  37. </div>
  38. <divclass="shadow"id="shadow1"></div>
  39. <divid="gear1"></div>
  40. <divid="gear-system-6">
  41. <divclass="shadow"id="shadow5"></div>
  42. <divid="gear5"></div>
  43. <divid="gear2"></div>
  44. </div>
  45. <divclass="shadow"id="shadowweight"></div>
  46. <divid="chain-circle"></div>
  47. <divid="chain"></div>
  48. <divid="weight"></div>
  49. </div>
  50. </div>
  51. </div>

CSS代码

CSS Code复制内容到剪贴板
  1. #level{
  2. width:100%;
  3. height:1px;
  4. position:absolute;
  5. top:50%;
  6. }
  7. #content{
  8. text-align:center;
  9. margin-top:-327px;
  10. }
  11. #gears{
  12. width:478px;
  13. height:655px;
  14. position:relative;
  15. display:inline-block;
  16. vertical-align:middle;
  17. }
  18. #gears-static{
  19. background:url(FgFnjks.png)no-repeat-363px-903px;
  20. width:329px;
  21. height:602px;
  22. position:absolute;
  23. bottombottom:5px;
  24. rightright:0px;
  25. opacity:0.4;
  26. }
  27. #title{
  28. vertical-align:middle;
  29. color:#9EB7B5;
  30. width:43%;
  31. display:inline-block;
  32. }
  33. #titleh1{
  34. font-family:'PTSansNarrowBold',sans-serif;
  35. font-size:3.6em;
  36. text-shadow:rgba(0,0,0,0.36)7px7px10px;
  37. }
  38. #titlep{
  39. font-family:sans-serif;
  40. font-size:1.2em;
  41. line-height:148%;
  42. text-shadow:rgba(0,0,0,0.36)1px1px0px;
  43. }
  44. .shadow{
  45. -webkit-box-shadow:4px7px25px10pxrgba(43,36,0,0.36);
  46. -moz-box-shadow:4px7px25px10pxrgba(43,36,0,0.36);
  47. box-shadow:4px7px25px10pxrgba(43,36,0,0.36);
  48. }
  49. /*gear-system-1*/
  50. #gear15{
  51. background:url(FgFnjks.png)no-repeat0-993px;
  52. width:321px;
  53. height:321px;
  54. position:absolute;
  55. left:45px;
  56. top:179px;
  57. -webkit-animation:rotate-back24000mslinearinfinite;
  58. -moz-animation:rotate-back24000mslinearinfinite;
  59. -ms-animation:rotate-back24000mslinearinfinite;
  60. animation:rotate-back24000mslinearinfinite;
  61. }
  62. #shadow15{
  63. width:306px;
  64. height:306px;
  65. -webkit-border-radius:153px;
  66. -moz-border-radius:153px;
  67. border-radius:153px;
  68. position:absolute;
  69. left:52px;
  70. top:186px;
  71. }
  72. #gear14{
  73. background:url(FgFnjks.png)no-repeat0-856px;
  74. width:87px;
  75. height:87px;
  76. position:absolute;
  77. left:162px;
  78. top:296px;
  79. }
  80. #shadow14{
  81. width:70px;
  82. height:70px;
  83. -webkit-border-radius:35px;
  84. -moz-border-radius:35px;
  85. border-radius:35px;
  86. position:absolute;
  87. left:171px;
  88. top:304px;
  89. }
  90. #gear13{
  91. background:url(FgFnjks.png)no-repeat0-744px;
  92. width:62px;
  93. height:62px;
  94. position:absolute;
  95. left:174px;
  96. top:309px;
  97. -webkit-animation:rotate8000mslinearinfinite;
  98. -moz-animation:rotate8000mslinearinfinite;
  99. -ms-animation:rotate8000mslinearinfinite;
  100. animation:rotate8000mslinearinfinite;
  101. }
  102. #shadow13{
  103. width:36px;
  104. height:36px;
  105. -webkit-border-radius:18px;
  106. -moz-border-radius:18px;
  107. border-radius:18px;
  108. position:absolute;
  109. left:187px;
  110. top:322px;
  111. }
  112. /*gear-system-2*/
  113. #gear10{
  114. background:url(FgFnjks.png)no-repeat0-184px;
  115. width:122px;
  116. height:122px;
  117. position:absolute;
  118. left:175px;
  119. top:0;
  120. -webkit-animation:rotate-back8000mslinearinfinite;
  121. -moz-animation:rotate-back8000mslinearinfinite;
  122. -ms-animation:rotate-back8000mslinearinfinite;
  123. animation:rotate-back8000mslinearinfinite;
  124. }
  125. #shadow10{
  126. width:86px;
  127. height:86px;
  128. -webkit-border-radius:43px;
  129. -moz-border-radius:43px;
  130. border-radius:43px;
  131. position:absolute;
  132. left:193px;
  133. top:18px;
  134. }
  135. #gear3{
  136. background:url(FgFnjks.png)no-repeat0-1493px;
  137. width:85px;
  138. height:84px;
  139. position:absolute;
  140. left:194px;
  141. top:19px;
  142. -webkit-animation:rotate10000mslinearinfinite;
  143. -moz-animation:rotate10000mslinearinfinite;
  144. -ms-animation:rotate10000mslinearinfinite;
  145. animation:rotate10000mslinearinfinite;
  146. }
  147. #shadow3{
  148. width:60px;
  149. height:60px;
  150. -webkit-border-radius:30px;
  151. -moz-border-radius:30px;
  152. border-radius:30px;
  153. position:absolute;
  154. left:206px;
  155. top:31px;
  156. }
  157. /*gear-system-3*/
  158. #gear9{
  159. background:url(FgFnjks.png)no-repeat-371px-280px;
  160. width:234px;
  161. height:234px;
  162. position:absolute;
  163. left:197px;
  164. top:96px;
  165. -webkit-animation:rotate12000mslinearinfinite;
  166. -moz-animation:rotate12000mslinearinfinite;
  167. -ms-animation:rotate12000mslinearinfinite;
  168. animation:rotate12000mslinearinfinite;
  169. }
  170. #shadow9{
  171. width:200px;
  172. height:200px;
  173. -webkit-border-radius:100px;
  174. -moz-border-radius:100px;
  175. border-radius:100px;
  176. position:absolute;
  177. left:214px;
  178. top:113px;
  179. }
  180. #gear7{
  181. background:url(FgFnjks.png)no-repeat-371px0;
  182. width:108px;
  183. height:108px;
  184. position:absolute;
  185. left:260px;
  186. top:159px;
  187. -webkit-animation:rotate-back10000mslinearinfinite;
  188. -moz-animation:rotate-back10000mslinearinfinite;
  189. -ms-animation:rotate-back10000mslinearinfinite;
  190. animation:rotate-back10000mslinearinfinite;
  191. }
  192. #shadow7{
  193. width:76px;
  194. height:76px;
  195. -webkit-border-radius:38px;
  196. -moz-border-radius:38px;
  197. border-radius:38px;
  198. position:absolute;
  199. left:276px;
  200. top:175px;
  201. }
  202. /*gear-system-4*/
  203. #gear6{
  204. background:url(FgFnjks.png)no-repeat0-1931px;
  205. width:134px;
  206. height:134px;
  207. position:absolute;
  208. left:305px;
  209. bottombottom:212px;
  210. -webkit-animation:rotate-back10000mslinearinfinite;
  211. -moz-animation:rotate-back10000mslinearinfinite;
  212. -ms-animation:rotate-back10000mslinearinfinite;
  213. animation:rotate-back10000mslinearinfinite;
  214. }
  215. #shadow6{
  216. width:98px;
  217. height:98px;
  218. -webkit-border-radius:49px;
  219. -moz-border-radius:49px;
  220. border-radius:49px;
  221. position:absolute;
  222. left:323px;
  223. bottombottom:230px;
  224. }
  225. #gear4{
  226. background:url(FgFnjks.png)no-repeat0-1627px;
  227. width:69px;
  228. height:69px;
  229. position:absolute;
  230. left:337px;
  231. bottombottom:245px;
  232. -webkit-animation:rotate-back10000mslinearinfinite;
  233. -moz-animation:rotate-back10000mslinearinfinite;
  234. -ms-animation:rotate-back10000mslinearinfinite;
  235. animation:rotate-back10000mslinearinfinite;
  236. }
  237. /*gear-system-5*/
  238. #gear12{
  239. background:url(FgFnjks.png)no-repeat0-530px;
  240. width:164px;
  241. height:164px;
  242. position:absolute;
  243. left:208px;
  244. bottombottom:85px;
  245. -webkit-animation:rotate8000mslinearinfinite;
  246. -moz-animation:rotate8000mslinearinfinite;
  247. -ms-animation:rotate8000mslinearinfinite;
  248. animation:rotate8000mslinearinfinite;
  249. }
  250. #shadow12{
  251. width:124px;
  252. height:124px;
  253. -webkit-border-radius:62px;
  254. -moz-border-radius:62px;
  255. border-radius:62px;
  256. position:absolute;
  257. left:225px;
  258. bottombottom:107px;
  259. }
  260. #gear11{
  261. background:url(FgFnjks.png)no-repeat0-356px;
  262. width:125px;
  263. height:124px;
  264. position:absolute;
  265. left:228px;
  266. bottombottom:105px;
  267. -webkit-animation:rotate-back10000mslinearinfinite;
  268. -moz-animation:rotate-back10000mslinearinfinite;
  269. -ms-animation:rotate-back10000mslinearinfinite;
  270. animation:rotate-back10000mslinearinfinite;
  271. }
  272. #shadow11{
  273. width:88px;
  274. height:88px;
  275. -webkit-border-radius:44px;
  276. -moz-border-radius:44px;
  277. border-radius:44px;
  278. position:absolute;
  279. left:247px;
  280. bottombottom:123px;
  281. }
  282. #gear8{
  283. background:url(FgFnjks.png)no-repeat-371px-158px;
  284. width:72px;
  285. height:72px;
  286. position:absolute;
  287. left:254px;
  288. bottombottom:131px;
  289. -webkit-animation:rotate6000mslinearinfinite;
  290. -moz-animation:rotate6000mslinearinfinite;
  291. -ms-animation:rotate6000mslinearinfinite;
  292. animation:rotate6000mslinearinfinite;
  293. }
  294. #shadow8{
  295. width:42px;
  296. height:42px;
  297. -webkit-border-radius:21px;
  298. -moz-border-radius:21px;
  299. border-radius:21px;
  300. position:absolute;
  301. left:269px;
  302. bottombottom:146px;
  303. }
  304. /*gear1*/
  305. #gear1{
  306. background:url(FgFnjks.png)no-repeat00;
  307. width:135px;
  308. height:134px;
  309. position:absolute;
  310. left:83px;
  311. bottombottom:111px;
  312. -webkit-animation:rotate-back10000mslinearinfinite;
  313. -moz-animation:rotate-back10000mslinearinfinite;
  314. -ms-animation:rotate-back10000mslinearinfinite;
  315. animation:rotate-back10000mslinearinfinite;
  316. }
  317. #shadow1{
  318. width:96px;
  319. height:96px;
  320. -webkit-border-radius:48px;
  321. -moz-border-radius:48px;
  322. border-radius:48px;
  323. position:absolute;
  324. left:103px;
  325. bottombottom:130px;
  326. }
  327. /*gear-system-6*/
  328. #gear5{
  329. background:url(FgFnjks.png)no-repeat0-1746px;
  330. width:134px;
  331. height:135px;
  332. position:absolute;
  333. left:22px;
  334. top:108px;
  335. -webkit-animation:rotate10000mslinearinfinitealternate;
  336. -moz-animation:rotate10000mslinearinfinitealternate;
  337. -ms-animation:rotate10000mslinearinfinitealternate;
  338. animation:rotate10000mslinearinfinitealternate;
  339. }
  340. #shadow5{
  341. width:96px;
  342. height:96px;
  343. -webkit-border-radius:48px;
  344. -moz-border-radius:48px;
  345. border-radius:48px;
  346. position:absolute;
  347. left:41px;
  348. top:127px;
  349. }
  350. #gear2{
  351. background:url(FgFnjks.png)no-repeat0-1364px;
  352. width:80px;
  353. height:79px;
  354. position:absolute;
  355. left:49px;
  356. top:136px;
  357. -webkit-animation:rotate-back10000mslinearinfinitealternate;
  358. -moz-animation:rotate-back10000mslinearinfinitealternate;
  359. -ms-animation:rotate-back10000mslinearinfinitealternate;
  360. animation:rotate-back10000mslinearinfinitealternate;
  361. }
  362. /*weight*/
  363. #weight{
  364. background:url(FgFnjks.png)no-repeat-371px-564px;
  365. width:34px;
  366. height:92px;
  367. position:absolute;
  368. left:1px;
  369. bottombottom:0;
  370. -webkit-animation:up10000mslinearinfinitealternate;
  371. -moz-animation:up10000mslinearinfinitealternate;
  372. -ms-animation:up10000mslinearinfinitealternate;
  373. animation:up10000mslinearinfinitealternate;
  374. }
  375. #shadowweight{
  376. width:10px;
  377. height:80px;
  378. position:absolute;
  379. left:12px;
  380. bottombottom:0px;
  381. -webkit-animation:up10000mslinearinfinitealternate;
  382. -moz-animation:up10000mslinearinfinitealternate;
  383. -ms-animation:up10000mslinearinfinitealternate;
  384. animation:up10000mslinearinfinitealternate;
  385. }
  386. /*chain*/
  387. #chain-circle{
  388. background:url(FgFnjks.png)no-repeat-371px-706px;
  389. width:146px;
  390. height:147px;
  391. position:absolute;
  392. left:17px;
  393. top:102px;
  394. -webkit-animation:rotate10000mslinearinfinitealternate;
  395. -moz-animation:rotate10000mslinearinfinitealternate;
  396. -ms-animation:rotate10000mslinearinfinitealternate;
  397. animation:rotate10000mslinearinfinitealternate;
  398. }
  399. #chain{
  400. width:1px;
  401. height:380px;
  402. border-left:2pxdotted#C8D94A;
  403. position:absolute;
  404. left:17px;
  405. top:175px;
  406. opacity:0.7;
  407. -webkit-animation:collapse10000mslinearinfinitealternate;
  408. -moz-animation:collapse10000mslinearinfinitealternate;
  409. -ms-animation:collapse10000mslinearinfinitealternate;
  410. animation:collapse10000mslinearinfinitealternate;
  411. }
  412. /*ANIMATIONS*/
  413. /*rotate*/
  414. @keyframes"rotate"{
  415. from{
  416. -webkit-transform:rotate(0deg);
  417. -moz-transform:rotate(0deg);
  418. -o-transform:rotate(0deg);
  419. -ms-transform:rotate(0deg);
  420. transform:rotate(0deg);
  421. }
  422. to{
  423. -webkit-transform:rotate(360deg);
  424. -moz-transform:rotate(360deg);
  425. -o-transform:rotate(360deg);
  426. -ms-transform:rotate(360deg);
  427. transform:rotate(360deg);
  428. }
  429. }
  430. @-moz-keyframesrotate{
  431. from{
  432. -moz-transform:rotate(0deg);
  433. transform:rotate(0deg);
  434. }
  435. to{
  436. -moz-transform:rotate(360deg);
  437. transform:rotate(360deg);
  438. }
  439. }
  440. @-webkit-keyframes"rotate"{
  441. from{
  442. -webkit-transform:rotate(0deg);
  443. transform:rotate(0deg);
  444. }
  445. to{
  446. -webkit-transform:rotate(360deg);
  447. transform:rotate(360deg);
  448. }
  449. }
  450. @-ms-keyframes"rotate"{
  451. from{
  452. -ms-transform:rotate(0deg);
  453. transform:rotate(0deg);
  454. }
  455. to{
  456. -ms-transform:rotate(360deg);
  457. transform:rotate(360deg);
  458. }
  459. }
  460. @-o-keyframes"rotate"{
  461. from{
  462. -o-transform:rotate(0deg);
  463. transform:rotate(0deg);
  464. }
  465. to{
  466. -o-transform:rotate(360deg);
  467. transform:rotate(360deg);
  468. }
  469. }
  470. /*rotate-back*/
  471. @keyframes"rotate-back"{
  472. from{
  473. -webkit-transform:rotate(0deg);
  474. -moz-transform:rotate(0deg);
  475. -o-transform:rotate(0deg);
  476. -ms-transform:rotate(0deg);
  477. transform:rotate(0deg);
  478. }
  479. to{
  480. -webkit-transform:rotate(-360deg);
  481. -moz-transform:rotate(-360deg);
  482. -o-transform:rotate(-360deg);
  483. -ms-transform:rotate(-360deg);
  484. transform:rotate(-360deg);
  485. }
  486. }
  487. @-moz-keyframesrotate-back{
  488. from{
  489. -moz-transform:rotate(0deg);
  490. transform:rotate(0deg);
  491. }
  492. to{
  493. -moz-transform:rotate(-360deg);
  494. transform:rotate(-360deg);
  495. }
  496. }
  497. @-webkit-keyframes"rotate-back"{
  498. from{
  499. -webkit-transform:rotate(0deg);
  500. transform:rotate(0deg);
  501. }
  502. to{
  503. -webkit-transform:rotate(-360deg);
  504. transform:rotate(-360deg);
  505. }
  506. }
  507. @-ms-keyframes"rotate-back"{
  508. from{
  509. -ms-transform:rotate(0deg);
  510. transform:rotate(0deg);
  511. }
  512. to{
  513. -ms-transform:rotate(-360deg);
  514. transform:rotate(-360deg);
  515. }
  516. }
  517. @-o-keyframes"rotate-back"{
  518. from{
  519. -o-transform:rotate(0deg);
  520. transform:rotate(0deg);
  521. }
  522. to{
  523. -o-transform:rotate(-360deg);
  524. transform:rotate(-360deg);
  525. }
  526. }
  527. /*weightup*/
  528. @keyframes"up"{
  529. from{
  530. bottombottom:0px;
  531. }
  532. to{
  533. bottombottom:340px;
  534. }
  535. }
  536. @-moz-keyframesup{
  537. from{
  538. bottombottom:0px;
  539. }
  540. to{
  541. bottombottom:340px;
  542. }
  543. }
  544. @-webkit-keyframes"up"{
  545. from{
  546. bottombottom:0px;
  547. }
  548. to{
  549. bottombottom:340px;
  550. }
  551. }
  552. @-ms-keyframes"up"{
  553. from{
  554. bottombottom:0px;
  555. }
  556. to{
  557. bottombottom:340px;
  558. }
  559. }
  560. @-o-keyframes"up"{
  561. from{
  562. bottombottom:0px;
  563. }
  564. to{
  565. bottombottom:340px;
  566. }
  567. }
  568. /*chainupanddown*/
  569. @keyframes"collapse"{
  570. from{
  571. height:387px;
  572. }
  573. to{
  574. height:48px;
  575. }
  576. }
  577. @-moz-keyframescollapse{
  578. from{
  579. height:387px;
  580. }
  581. to{
  582. height:48px;
  583. }
  584. }
  585. @-webkit-keyframes"collapse"{
  586. from{
  587. height:387px;
  588. }
  589. to{
  590. height:48px;
  591. }
  592. }
  593. @-ms-keyframes"collapse"{
  594. from{
  595. height:387px;
  596. }
  597. to{
  598. height:48px;
  599. }
  600. }
  601. @-o-keyframes"collapse"{
  602. from{
  603. height:387px;
  604. }
  605. to{
  606. height:48px;
  607. }
  608. }

纯CSS3实现的齿轮动画特效,希望大家喜欢。

本文基于HTML5的齿轮动画特效到此结束。生活中总会有伤害你的人,所发你仍然需要继续相信别人,只是小心些而已。小编再次感谢大家对我们的支持!