欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2023-12-02 19:37:46
今天给大家分享一款非常漂亮的纯html5实现的时钟。整个界面都由html5绘制而成。下面我们来看看具体实现的代码,需要的朋友可以参考下... 15-01-04...

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

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

  实现的代码。

  htm代码:

xml/html code复制内容到剪贴板
  1. <div class="container">  
  2.         <svg width="600" height="600" class='svg-element'>  
  3.        
  4.     <filter id="f4" x="-50%" y="-20%" width="200%" height="140%">  
  5.       <feoffset result="offout" in="sourcealpha" dx="0" dy="25" />  
  6.       <fegaussianblur result="blurout" in="offout" stddeviation="10" />  
  7.       <feblend in="sourcegraphic" in2="blurout" mode="normal" />  
  8.     </filter>  
  9.        
  10.   <filter id="blurred-source" x="-50%" y="-20%" width="200%" height="140%">  
  11.     <fegaussianblur in="color" stddeviation="5" result="blurout"/>  
  12.   </filter>  
  13.         
  14.     <filter id="inset-shadow">  
  15.         <feoffset dx="0" dy="10"/>                                                         <!-- shadow offset -->  
  16.         <fegaussianblur stddeviation="15"  result="offset-blur"/>                           <!-- shadow blur -->  
  17.         <fecomposite operator="out" in="sourcegraphic" in2="offset-blur" result="inverse"/> <!-- invert the drop shadow to create an inner shadow -->  
  18.         <feflood flood-color="black" flood-opacity="1" result="color"/>                     <!-- color & opacity -->  
  19.         <fecomposite operator="in" in="color" in2="inverse" result="shadow"/>               <!-- clip color inside shadow -->  
  20.         <fecomponenttransfer in="shadow" result="shadow">                                   <!-- shadow opacity -->  
  21.             <fefunca type="linear" slope="1"/>  
  22.         </fecomponenttransfer>  
  23.         <fecomposite operator="over" in="shadow" in2="sourcegraphic"/>                    <!-- put shadow over original object -->  
  24.     </filter>  
  25.        
  26.     <filter id="inset-shadow-big">  
  27.         <feoffset dx="0" dy="4"/>                                                         <!-- shadow offset -->  
  28.         <fegaussianblur stddeviation="2"  result="offset-blur"/>                           <!-- shadow blur -->  
  29.         <fecomposite operator="out" in="sourcegraphic" in2="offset-blur" result="inverse"/> <!-- invert the drop shadow to create an inner shadow -->  
  30.         <feflood flood-color="white" flood-opacity="1" result="color"/>                     <!-- color & opacity -->  
  31.         <fecomposite operator="in" in="color" in2="inverse" result="shadow"/>               <!-- clip color inside shadow -->  
  32.         <fecomponenttransfer in="shadow" result="shadow">                                   <!-- shadow opacity -->  
  33.             <fefunca type="linear" slope="0.5"/>  
  34.         </fecomponenttransfer>  
  35.         <fecomposite operator="over" in="shadow" in2="sourcegraphic"/>                    <!-- put shadow over original object -->  
  36.     </filter>  
  37.        
  38.     <filter id="inset-shadow-big-bottom">  
  39.         <feoffset dx="0" dy="10"/>                                                         <!-- shadow offset -->  
  40.         <fegaussianblur stddeviation="2"  result="offset-blur"/>                           <!-- shadow blur -->  
  41.         <fecomposite operator="out" in="sourcegraphic" in2="offset-blur" result="inverse"/> <!-- invert the drop shadow to create an inner shadow -->  
  42.         <feflood flood-color="#fff" flood-opacity="1" result="color"/>                     <!-- color & opacity -->  
  43.         <fecomposite operator="in" in="color" in2="inverse" result="shadow"/>               <!-- clip color inside shadow -->  
  44.         <fecomponenttransfer in="shadow" result="shadow">                                   <!-- shadow opacity -->  
  45.             <fefunca type="linear" slope="0.5"/>  
  46.         </fecomponenttransfer>  
  47.         <fecomposite operator="over" in="shadow" in2="sourcegraphic" result='final-shadow-1'/>                    <!-- put shadow over original object -->  
  48.          
  49.         <feoffset dx="0" dy="-12"/>                                                         <!-- shadow offset -->  
  50.         <fegaussianblur stddeviation="2"  result="offset-blur"/>                           <!-- shadow blur -->  
  51.         <fecomposite operator="out" in="final-shadow-1" in2="offset-blur" result="inverse"/> <!-- invert the drop shadow to create an inner shadow -->  
  52.         <feflood flood-color="#69c39b" flood-opacity="1" result="color"/>                     <!-- color & opacity -->  
  53.         <fecomposite operator="in" in="color" in2="inverse" result="shadow"/>               <!-- clip color inside shadow -->  
  54.         <fecomponenttransfer in="shadow" result="shadow">                                   <!-- shadow opacity -->  
  55.             <fefunca type="linear" slope="0.5"/>  
  56.         </fecomponenttransfer>  
  57.         <fecomposite operator="over" in="shadow" in2="final-shadow-1" result='final-shadow-2'/>                    <!-- put shadow over original object -->  
  58.          
  59.     </filter>  
  60.        
  61.     <lineargradient id="lg"  
  62.                     gradienttransform="rotate(90 .5 .5)">         
  63.       <stop id="s0" offset="0" stop-color="#d6f8e9"/>  
  64.       <stop id="s2" offset="1" stop-color="#9ee1c4"/>  
  65.     </lineargradient>  
  66.        
  67.     <lineargradient id="lg2"  
  68.                     gradienttransform="rotate(-90 .5 .5)">         
  69.       <stop id="s0" offset="0.07" stop-color="#fdfefe"/>  
  70.       <stop id="s1" offset="0.5" stop-color="#98e2c2"/>  
  71.       <stop id="s2" offset="0.8" stop-color="#79c9a7"/>  
  72.       <stop id="s3" offset="1" stop-color="#5fbc95"/>  
  73.     </lineargradient>  
  74.        
  75.     <lineargradient id="arrow1"  
  76.                     gradienttransform="rotate(-90 .5 .5)">         
  77.       <stop id="s0" offset="0" stop-color="#07594f"/>  
  78.       <stop id="s2" offset="1" stop-color="#01443c"/>  
  79.     </lineargradient>  
  80.        
  81.     <lineargradient id="arrowred"  
  82.                     gradienttransform="rotate(-90 .5 .5)">         
  83.       <stop id="s0" offset="0" stop-color="#fd5959"/>  
  84.       <stop id="s2" offset="1" stop-color="#fe7c7c"/>  
  85.     </lineargradient>  
  86.        
  87.     <lineargradient id="center-knob-outter"  
  88.                     gradienttransform="rotate(90 .5 .5)">         
  89.       <stop id="s0" offset="0" stop-color="#fffefe"/>  
  90.       <stop id="s2" offset="1" stop-color="#86ecdb"/>  
  91.     </lineargradient>  
  92.        
  93.         <lineargradient id="center-knob-inner"  
  94.                     gradienttransform="rotate(90 .5 .5)">         
  95.       <stop id="s0" offset="0" stop-color="#a0dcd2"/>  
  96.       <stop id="s2" offset="1" stop-color="#dff9ef"/>  
  97.     </lineargradient>  
  98.        
  99.     <g transform="translate(50, 20)">  
  100.          
  101.       <rect x="0" y="0"  
  102.           width="382" height="382"    
  103.           fill="url(#lg)"  
  104.           filter="url(#inset-shadow-big-bottom)"  
  105.           rx="75" ry="105" />  
  106.        
  107.     <circle cx="191" cy="191" r="155" fill="url(#lg2)"/>  
  108.     <circle cx="191" cy="191" r="130" fill="#53d2c5"/>  
  109.     <circle cx="191" cy="191" r="130" fill="#53d2c5" filter="url(#inset-shadow)" />  
  110.        
  111.       <g width="200" height="200"  
  112.        transform="translate(100, 100)">  
  113.        <animatetransform attributename="transform" type="translate" dur="4s"    
  114.        values="191,191;191,191" repeatcount="indefinite"/>  
  115.        <animatetransform attributename="transform" additive="sum" type="rotate"    
  116.        dur="86400s" values="200, 0 0;550 0 0" repeatcount="indefinite"/>  
  117.          
  118.           <rect x="0" y="0"  
  119.                 width="22" height="70"    
  120.                 fill="url(#arrow1)"  
  121.                 fill-opacity="0.5"  
  122.                 filter="url(#blurred-source)"  
  123.                 rx="10" ry="10"  
  124.                 transform="translate(-11, -15)" />  
  125.     </g>     
  126.          
  127.     <g width="200" height="200"  
  128.        transform="translate(100, 100)">  
  129.        <animatetransform attributename="transform" type="translate" dur="4s"    
  130.        values="191,191;191,191" repeatcount="indefinite"/>  
  131.        <animatetransform attributename="transform" additive="sum" type="rotate"    
  132.        dur="86400s" values="200, 0 0;550 0 0" repeatcount="indefinite"/>  
  133.          
  134.           <rect x="0" y="0"  
  135.                 width="20" height="70"    
  136.                 fill="url(#arrow1)"  
  137.                 rx="10" ry="10"  
  138.                 transform="translate(-10, -10)" />  
  139.     </g>  
  140.        
  141.       <g width="200" height="200"  
  142.        transform="translate(100, 100)">  
  143.        <animatetransform attributename="transform" type="translate" dur="4s"    
  144.        values="191,191;191,191" repeatcount="indefinite"/>  
  145.        <animatetransform attributename="transform" additive="sum" type="rotate"    
  146.        dur="3600s" values="90,0 0;450 0 0" repeatcount="indefinite"/>  
  147.          
  148.       <rect x="0" y="0"  
  149.             width="18" height="104"    
  150.             fill="url(#arrow1)"  
  151.             fill-opacity="0.8"  
  152.             filter="url(#blurred-source)"  
  153.             rx="8" ry="8"  
  154.             transform="translate(-9, -15)"> />  
  155.     </g>      
  156.          
  157.     <g width="200" height="200"  
  158.        transform="translate(100, 100)">  
  159.        <animatetransform attributename="transform" type="translate" dur="4s"    
  160.        values="191,191;191,191" repeatcount="indefinite"/>  
  161.        <animatetransform attributename="transform" additive="sum" type="rotate"    
  162.        dur="3600s" values="90,0 0;450 0 0" repeatcount="indefinite"/>  
  163.          
  164.       <rect x="0" y="0"  
  165.             width="16" height="104"    
  166.             fill="url(#arrow1)"  
  167.             rx="8" ry="8"  
  168.             transform="translate(-8, -8)"> />  
  169.     </g>  
  170.        
  171.      <g width="200" height="200">  
  172.        <animatetransform attributename="transform" type="translate" dur="4s"    
  173.        values="195,195;190,195" repeatcount="indefinite"/>  
  174.        <animatetransform attributename="transform" additive="sum" type="rotate"    
  175.        dur="60s" values="0,0 0;360 0 0" repeatcount="indefinite"/>  
  176.          
  177.       <rect class="arrowred"  
  178.             x="0" y="0"  
  179.             width="8" height="120"    
  180.             fill="url(#arrowred)"  
  181.             filter="url(#blurred-source)"  
  182.             fill-opacity="0.5"  
  183.             rx="3" ry="3"  
  184.             transform="translate(-3, -20)"/>  
  185.     </g>  
  186.          
  187.        
  188.     <g width="200" height="200"  
  189.        transform="translate(100, 100)">  
  190.        <animatetransform attributename="transform" type="translate" dur="4s"    
  191.        values="191,191;191,191" repeatcount="indefinite"/>  
  192.        <animatetransform attributename="transform" additive="sum" type="rotate"    
  193.        dur="60s" values="0,0 0;360 0 0" repeatcount="indefinite"/>  
  194.          
  195.       <rect class="arrowred"  
  196.             x="0" y="0"  
  197.             width="6" height="134"    
  198.             fill="url(#arrowred)"  
  199.             rx="3" ry="3"  
  200.             transform="translate(-3, -20)"/>  
  201.     </g>  
  202.          
  203.   
  204.        
  205.            
  206.     <g width="200" height="200"  
  207.        transform="translate(191, 191)">  
  208.          
  209.       <circle cx="0" cy="0" r="19" fill="url(#center-knob-outter)"/>  
  210.       <circle cx="0" cy="0" r="10" fill="url(#center-knob-inner)"/>  
  211.     </g>  
  212.          
  213. <!--      <path d="m 200 20    
  214.                 200 40    
  215.                 180 30 z">-->  
  216.   
  217.       </g>  
  218.     </div>  

  css3代码:

css code复制内容到剪贴板
  1. .container   
  2.         {   
  3.             text-aligncenter;   
  4.             width: 100%;   
  5.             margin-top20px;   
  6.             padding20px;   
  7.         }