最新赞助活动温馨提示:自愿赞助服务器费用,学生和没有工作的整站资源免费下载!
头像

基于HTML5的齿轮动画特效_html5教程技巧-H5教程

来源:http://erdangjiade.com/topic/134610.html H5程序员 2017-10-19 10:30浏览(50)

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

HTML代码

XML/HTML Code复制内容到剪贴板

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

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. #title h1{
  34. font-family: 'PTSansNarrowBold', sans-serif;
  35. font-size:3.6em;
  36. text-shadow:rgba(0, 0, 0, 0.36) 7px 7px 10px;
  37. }
  38. #title p{
  39. font-family: sans-serif;
  40. font-size:1.2em;
  41. line-height:148%;
  42. text-shadow:rgba(0, 0, 0, 0.36) 1px 1px 0px;
  43. }
  44. .shadow{
  45. -webkit-box-shadow: 4px 7px 25px 10px rgba(43, 36, 0, 0.36);
  46. -moz-box-shadow: 4px 7px 25px 10px rgba(43, 36, 0, 0.36);
  47. box-shadow: 4px 7px 25px 10px rgba(43, 36, 0, 0.36);
  48. }
  49. /*gear-system-1*/
  50. #gear15{
  51. background: url(FgFnjks.png) no-repeat 0 -993px;
  52. width: 321px;
  53. height: 321px;
  54. position:absolute;
  55. left:45px;
  56. top:179px;
  57. -webkit-animation: rotate-back 24000ms linear infinite;
  58. -moz-animation: rotate-back 24000ms linear infinite;
  59. -ms-animation: rotate-back 24000ms linear infinite;
  60. animation: rotate-back 24000ms linear infinite;
  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-repeat 0 -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-repeat 0 -744px;
  92. width: 62px;
  93. height: 62px;
  94. position:absolute;
  95. left:174px;
  96. top:309px;
  97. -webkit-animation: rotate 8000ms linear infinite;
  98. -moz-animation: rotate 8000ms linear infinite;
  99. -ms-animation: rotate 8000ms linear infinite;
  100. animation: rotate 8000ms linear infinite;
  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-repeat 0 -184px;
  115. width: 122px;
  116. height: 122px;
  117. position:absolute;
  118. left:175px;
  119. top:0;
  120. -webkit-animation: rotate-back 8000ms linear infinite;
  121. -moz-animation: rotate-back 8000ms linear infinite;
  122. -ms-animation: rotate-back 8000ms linear infinite;
  123. animation: rotate-back 8000ms linear infinite;
  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-repeat 0 -1493px;
  137. width: 85px;
  138. height: 84px;
  139. position:absolute;
  140. left:194px;
  141. top:19px;
  142. -webkit-animation: rotate 10000ms linear infinite;
  143. -moz-animation: rotate 10000ms linear infinite;
  144. -ms-animation: rotate 10000ms linear infinite;
  145. animation: rotate 10000ms linear infinite;
  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: rotate 12000ms linear infinite;
  166. -moz-animation: rotate 12000ms linear infinite;
  167. -ms-animation: rotate 12000ms linear infinite;
  168. animation: rotate 12000ms linear infinite;
  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 -371px 0;
  182. width: 108px;
  183. height: 108px;
  184. position:absolute;
  185. left:260px;
  186. top:159px;
  187. -webkit-animation: rotate-back 10000ms linear infinite;
  188. -moz-animation: rotate-back 10000ms linear infinite;
  189. -ms-animation: rotate-back 10000ms linear infinite;
  190. animation: rotate-back 10000ms linear infinite;
  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-repeat 0 -1931px;
  205. width: 134px;
  206. height: 134px;
  207. position:absolute;
  208. left:305px;
  209. bottombottom:212px;
  210. -webkit-animation: rotate-back 10000ms linear infinite;
  211. -moz-animation: rotate-back 10000ms linear infinite;
  212. -ms-animation: rotate-back 10000ms linear infinite;
  213. animation: rotate-back 10000ms linear infinite;
  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-repeat 0 -1627px;
  227. width: 69px;
  228. height: 69px;
  229. position:absolute;
  230. left:337px;
  231. bottombottom:245px;
  232. -webkit-animation: rotate-back 10000ms linear infinite;
  233. -moz-animation: rotate-back 10000ms linear infinite;
  234. -ms-animation: rotate-back 10000ms linear infinite;
  235. animation: rotate-back 10000ms linear infinite;
  236. }
  237. /*gear-system-5*/
  238. #gear12{
  239. background: url(FgFnjks.png) no-repeat 0 -530px;
  240. width: 164px;
  241. height: 164px;
  242. position:absolute;
  243. left:208px;
  244. bottombottom:85px;
  245. -webkit-animation: rotate 8000ms linear infinite;
  246. -moz-animation: rotate 8000ms linear infinite;
  247. -ms-animation: rotate 8000ms linear infinite;
  248. animation: rotate 8000ms linear infinite;
  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-repeat 0 -356px;
  262. width: 125px;
  263. height: 124px;
  264. position:absolute;
  265. left:228px;
  266. bottombottom:105px;
  267. -webkit-animation: rotate-back 10000ms linear infinite;
  268. -moz-animation: rotate-back 10000ms linear infinite;
  269. -ms-animation: rotate-back 10000ms linear infinite;
  270. animation: rotate-back 10000ms linear infinite;
  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: rotate 6000ms linear infinite;
  290. -moz-animation: rotate 6000ms linear infinite;
  291. -ms-animation: rotate 6000ms linear infinite;
  292. animation: rotate 6000ms linear infinite;
  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-repeat 0 0;
  307. width: 135px;
  308. height: 134px;
  309. position:absolute;
  310. left:83px;
  311. bottombottom:111px;
  312. -webkit-animation: rotate-back 10000ms linear infinite;
  313. -moz-animation: rotate-back 10000ms linear infinite;
  314. -ms-animation: rotate-back 10000ms linear infinite;
  315. animation: rotate-back 10000ms linear infinite;
  316. }
  317. #shadow1{
  318. width:96px;
  319. height:96px;
  320. -webkit-border-radius:48px;
  321. -moz-border-radius:48px;
  322. border-radius:48px;
评论0
头像

友情提示:垃圾评论一律封号 加我微信:826096331拉你进VIP群学习群

1 2