如何利用纯html5绘制出来的一款非常漂亮的时钟

少了你的风景,我没有美丽的人生。天气真好!一起去郊游吧,拥抱大自然,呼吸清新的空气,享受悠闲和温馨。

  今天给大家分享一款非常漂亮的纯html5实现的时钟。整个界面都由html5绘制而成。一起看下效果图:

  实现的代码。

  htm代码:

XML/HTML Code复制内容到剪贴板
  1. <divclass="container">
  2. <svgwidth="600"height="600"class='svg-element'>
  3. <filterid="f4"x="-50%"y="-20%"width="200%"height="140%">
  4. <feOffsetresult="offOut"in="SourceAlpha"dx="0"dy="25"/>
  5. <feGaussianBlurresult="blurOut"in="offOut"stdDeviation="10"/>
  6. <feBlendin="SourceGraphic"in2="blurOut"mode="normal"/>
  7. </filter>
  8. <filterid="blurred-source"x="-50%"y="-20%"width="200%"height="140%">
  9. <feGaussianBlurin="color"stdDeviation="5"result="blurOut"/>
  10. </filter>
  11. <filterid="inset-shadow">
  12. <feOffsetdx="0"dy="10"/><!--ShadowOffset-->
  13. <feGaussianBlurstdDeviation="15"result="offset-blur"/><!--ShadowBlur-->
  14. <feCompositeoperator="out"in="SourceGraphic"in2="offset-blur"result="inverse"/><!--Invertthedropshadowtocreateaninnershadow-->
  15. <feFloodflood-color="black"flood-opacity="1"result="color"/><!--Color&Opacity-->
  16. <feCompositeoperator="in"in="color"in2="inverse"result="shadow"/><!--Clipcolorinsideshadow-->
  17. <feComponentTransferin="shadow"result="shadow"><!--ShadowOpacity-->
  18. <feFuncAtype="linear"slope="1"/>
  19. </feComponentTransfer>
  20. <feCompositeoperator="over"in="shadow"in2="SourceGraphic"/><!--Putshadowoveroriginalobject-->
  21. </filter>
  22. <filterid="inset-shadow-big">
  23. <feOffsetdx="0"dy="4"/><!--ShadowOffset-->
  24. <feGaussianBlurstdDeviation="2"result="offset-blur"/><!--ShadowBlur-->
  25. <feCompositeoperator="out"in="SourceGraphic"in2="offset-blur"result="inverse"/><!--Invertthedropshadowtocreateaninnershadow-->
  26. <feFloodflood-color="white"flood-opacity="1"result="color"/><!--Color&Opacity-->
  27. <feCompositeoperator="in"in="color"in2="inverse"result="shadow"/><!--Clipcolorinsideshadow-->
  28. <feComponentTransferin="shadow"result="shadow"><!--ShadowOpacity-->
  29. <feFuncAtype="linear"slope="0.5"/>
  30. </feComponentTransfer>
  31. <feCompositeoperator="over"in="shadow"in2="SourceGraphic"/><!--Putshadowoveroriginalobject-->
  32. </filter>
  33. <filterid="inset-shadow-big-bottom">
  34. <feOffsetdx="0"dy="10"/><!--ShadowOffset-->
  35. <feGaussianBlurstdDeviation="2"result="offset-blur"/><!--ShadowBlur-->
  36. <feCompositeoperator="out"in="SourceGraphic"in2="offset-blur"result="inverse"/><!--Invertthedropshadowtocreateaninnershadow-->
  37. <feFloodflood-color="#FFF"flood-opacity="1"result="color"/><!--Color&Opacity-->
  38. <feCompositeoperator="in"in="color"in2="inverse"result="shadow"/><!--Clipcolorinsideshadow-->
  39. <feComponentTransferin="shadow"result="shadow"><!--ShadowOpacity-->
  40. <feFuncAtype="linear"slope="0.5"/>
  41. </feComponentTransfer>
  42. <feCompositeoperator="over"in="shadow"in2="SourceGraphic"result='final-shadow-1'/><!--Putshadowoveroriginalobject-->
  43. <feOffsetdx="0"dy="-12"/><!--ShadowOffset-->
  44. <feGaussianBlurstdDeviation="2"result="offset-blur"/><!--ShadowBlur-->
  45. <feCompositeoperator="out"in="final-shadow-1"in2="offset-blur"result="inverse"/><!--Invertthedropshadowtocreateaninnershadow-->
  46. <feFloodflood-color="#69c39b"flood-opacity="1"result="color"/><!--Color&Opacity-->
  47. <feCompositeoperator="in"in="color"in2="inverse"result="shadow"/><!--Clipcolorinsideshadow-->
  48. <feComponentTransferin="shadow"result="shadow"><!--ShadowOpacity-->
  49. <feFuncAtype="linear"slope="0.5"/>
  50. </feComponentTransfer>
  51. <feCompositeoperator="over"in="shadow"in2="final-shadow-1"result='final-shadow-2'/><!--Putshadowoveroriginalobject-->
  52. </filter>
  53. <linearGradientid="LG"
  54. gradientTransform="rotate(90.5.5)">
  55. <stopid="s0"offset="0"stop-color="#d6f8e9"/>
  56. <stopid="s2"offset="1"stop-color="#9ee1c4"/>
  57. </linearGradient>
  58. <linearGradientid="LG2"
  59. gradientTransform="rotate(-90.5.5)">
  60. <stopid="s0"offset="0.07"stop-color="#fdfefe"/>
  61. <stopid="s1"offset="0.5"stop-color="#98e2c2"/>
  62. <stopid="s2"offset="0.8"stop-color="#79c9a7"/>
  63. <stopid="s3"offset="1"stop-color="#5fbc95"/>
  64. </linearGradient>
  65. <linearGradientid="arrow1"
  66. gradientTransform="rotate(-90.5.5)">
  67. <stopid="s0"offset="0"stop-color="#07594f"/>
  68. <stopid="s2"offset="1"stop-color="#01443c"/>
  69. </linearGradient>
  70. <linearGradientid="arrowRed"
  71. gradientTransform="rotate(-90.5.5)">
  72. <stopid="s0"offset="0"stop-color="#fd5959"/>
  73. <stopid="s2"offset="1"stop-color="#fe7c7c"/>
  74. </linearGradient>
  75. <linearGradientid="center-knob-outter"
  76. gradientTransform="rotate(90.5.5)">
  77. <stopid="s0"offset="0"stop-color="#fffefe"/>
  78. <stopid="s2"offset="1"stop-color="#86ecdb"/>
  79. </linearGradient>
  80. <linearGradientid="center-knob-inner"
  81. gradientTransform="rotate(90.5.5)">
  82. <stopid="s0"offset="0"stop-color="#a0dcd2"/>
  83. <stopid="s2"offset="1"stop-color="#dff9ef"/>
  84. </linearGradient>
  85. <gtransform="translate(50,20)">
  86. <rectx="0"y="0"
  87. width="382"height="382"
  88. fill="url(#LG)"
  89. filter="url(#inset-shadow-big-bottom)"
  90. rx="75"ry="105"/>
  91. <circlecx="191"cy="191"r="155"fill="url(#LG2)"/>
  92. <circlecx="191"cy="191"r="130"fill="#53d2c5"/>
  93. <circlecx="191"cy="191"r="130"fill="#53d2c5"filter="url(#inset-shadow)"/>
  94. <gwidth="200"height="200"
  95. transform="translate(100,100)">
  96. <animateTransformattributeName="transform"type="translate"dur="4s"
  97. values="191,191;191,191"repeatCount="indefinite"/>
  98. <animateTransformattributeName="transform"additive="sum"type="rotate"
  99. dur="86400s"values="200,00;55000"repeatCount="indefinite"/>
  100. <rectx="0"y="0"
  101. width="22"height="70"
  102. fill="url(#arrow1)"
  103. fill-opacity="0.5"
  104. filter="url(#blurred-source)"
  105. rx="10"ry="10"
  106. transform="translate(-11,-15)"/>
  107. </g>
  108. <gwidth="200"height="200"
  109. transform="translate(100,100)">
  110. <animateTransformattributeName="transform"type="translate"dur="4s"
  111. values="191,191;191,191"repeatCount="indefinite"/>
  112. <animateTransformattributeName="transform"additive="sum"type="rotate"
  113. dur="86400s"values="200,00;55000"repeatCount="indefinite"/>
  114. <rectx="0"y="0"
  115. width="20"height="70"
  116. fill="url(#arrow1)"
  117. rx="10"ry="10"
  118. transform="translate(-10,-10)"/>
  119. </g>
  120. <gwidth="200"height="200"
  121. transform="translate(100,100)">
  122. <animateTransformattributeName="transform"type="translate"dur="4s"
  123. values="191,191;191,191"repeatCount="indefinite"/>
  124. <animateTransformattributeName="transform"additive="sum"type="rotate"
  125. dur="3600s"values="90,00;45000"repeatCount="indefinite"/>
  126. <rectx="0"y="0"
  127. width="18"height="104"
  128. fill="url(#arrow1)"
  129. fill-opacity="0.8"
  130. filter="url(#blurred-source)"
  131. rx="8"ry="8"
  132. transform="translate(-9,-15)">/>
  133. </g>
  134. <gwidth="200"height="200"
  135. transform="translate(100,100)">
  136. <animateTransformattributeName="transform"type="translate"dur="4s"
  137. values="191,191;191,191"repeatCount="indefinite"/>
  138. <animateTransformattributeName="transform"additive="sum"type="rotate"
  139. dur="3600s"values="90,00;45000"repeatCount="indefinite"/>
  140. <rectx="0"y="0"
  141. width="16"height="104"
  142. fill="url(#arrow1)"
  143. rx="8"ry="8"
  144. transform="translate(-8,-8)">/>
  145. </g>
  146. <gwidth="200"height="200">
  147. <animateTransformattributeName="transform"type="translate"dur="4s"
  148. values="195,195;190,195"repeatCount="indefinite"/>
  149. <animateTransformattributeName="transform"additive="sum"type="rotate"
  150. dur="60s"values="0,00;36000"repeatCount="indefinite"/>
  151. <rectclass="arrowRed"
  152. x="0"y="0"
  153. width="8"height="120"
  154. fill="url(#arrowRed)"
  155. filter="url(#blurred-source)"
  156. fill-opacity="0.5"
  157. rx="3"ry="3"
  158. transform="translate(-3,-20)"/>
  159. </g>
  160. <gwidth="200"height="200"
  161. transform="translate(100,100)">
  162. <animateTransformattributeName="transform"type="translate"dur="4s"
  163. values="191,191;191,191"repeatCount="indefinite"/>
  164. <animateTransformattributeName="transform"additive="sum"type="rotate"
  165. dur="60s"values="0,00;36000"repeatCount="indefinite"/>
  166. <rectclass="arrowRed"
  167. x="0"y="0"
  168. width="6"height="134"
  169. fill="url(#arrowRed)"
  170. rx="3"ry="3"
  171. transform="translate(-3,-20)"/>
  172. </g>
  173. <gwidth="200"height="200"
  174. transform="translate(191,191)">
  175. <circlecx="0"cy="0"r="19"fill="url(#center-knob-outter)"/>
  176. <circlecx="0"cy="0"r="10"fill="url(#center-knob-inner)"/>
  177. </g>
  178. <!--<pathd="M20020
  179. 20040
  180. 18030z">-->
  181. </g>
  182. </div>

  css3代码:

CSS Code复制内容到剪贴板
  1. .container
  2. {
  3. text-align:center;
  4. width:100%;
  5. margin-top:20px;
  6. padding:20px;
  7. }

本文如何利用纯html5绘制出来的一款非常漂亮的时钟到此结束。快乐的人不是没有痛苦,而是不会被痛苦所左右。人生难免会和痛苦不期而遇,其实痛苦并不可怕,可怕的是内心背叛自己。整理一下自己的心情,忘记那些不愉快的往事,听听音乐,弹弹钢琴,看看风景,说能说的话,做个单纯的人,走幸福的路。带上微笑,和快乐一起出发吧。小编再次感谢大家对我们的支持!