zoukankan      html  css  js  c++  java
  • svg实现圆环进度条

    开源实现:https://github.com/lugolabs/circles

    自行实现:圆环与svg画布间剩的空间太多。

        
    <!DOCTYPE html>
    <html> 
    <head> 
    <meta charset=" utf-8"> 
    <title>圆环进度条</title> 
    <style type="text/css">
    circle{
      -webkit-transition: stroke-dasharray .25s;
      transition: stroke-dasharray .25s;
    }
    </style>
    <script>
    window.onload = function () {
      if (window.addEventListener) {
        var range = document.querySelector("#range");
        var circle = document.querySelectorAll("circle")[1];
        if (range && circle) {
          range.addEventListener("change", function () {
            console.log(this.value,2*Math.PI*50);
            var percent = this.value / 100, lineLength = 2*Math.PI * 50;
            circle.setAttribute('stroke-dasharray', lineLength* percent + " " + lineLength * (1 - percent));
          });
        }
      }
    }
    </script>
    </head>
    <body>
    <svg width="200" height="200">
      <circle cx="100" cy="100" r="50" stroke-width="10" stroke="#D1D3D7" fill="none"></circle>
      <circle cx="100" cy="100" r="50" stroke-width="10" stroke="#00A5E0" fill="none"  stroke-dasharray="0 50">
      </circle>
    </svg>
    <p>拖我:<input id="range" type="range" min="0" max="100" value="0" style="300px;"></p>
    </body>
    </html>
  • 相关阅读:
    fpga不错的源代码下载地址
    iverilog命令选项解释
    altera官方视频教程下载地址
    niosII EDS和QuartusII安装心得体会
    FPGA的JTAG口很脆弱?
    poj2379
    poj2472
    poj2935
    poj3366
    poj1493
  • 原文地址:https://www.cnblogs.com/94pm/p/11515628.html
Copyright © 2011-2022 走看看