Search code examples
htmlcsssvgcss-shapes

Circle border progress bar


How can I create this circular progress bar with CSS is it even possible (compatible IE10+, FF, chrome, safari...)?
I think we can use SVG for this but I don't know how to make this.

Around the circle, there is a small border or shadow that changes dynamically according to a progress percentage. If the percentage is 100%, the border will be completly around the circle filling the progress bar.

circle progress bar with a border to show progress


Solution

  • This Circle progress bar is is adapted form this answer : circular progress bar

    It uses SVG with Snap.svg to animate the blue stroke and JS for the counter :

    Circle progress bar

    var count = $(('#count'));
    $({ Counter: 0 }).animate({ Counter: count.text() }, {
      duration: 5000,
      easing: 'linear',
      step: function () {
        count.text(Math.ceil(this.Counter)+ "%");
      }
    });
    
    var s = Snap('#animated');
    var progress = s.select('#progress');
    
    progress.attr({strokeDasharray: '0, 251.2'});
    Snap.animate(0,251.2, function( value ) {
        progress.attr({ 'stroke-dasharray':value+',251.2'});
    }, 5000);
    body{text-align:center;font-family:sans-serif;background:#080808;}
    svg{width:25%;}
    <script src="https://cdnjs.cloudflare.com/ajax/libs/snap.svg/0.3.0/snap.svg-min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <svg id="animated" viewbox="0 0 100 100">
      <path id="progress" stroke-width="3" stroke="#4596AB" fill="none"
            d="M50 10
               a 40 40 0 0 1 0 80
               a 40 40 0 0 1 0 -80">
      </path>
      <circle cx="50" cy="50" r="38" fill="transparent" stroke="#fff" stroke-width="1"/>
      <text id="count" x="50" y="50" fill="#fff" text-anchor="middle" dy="7" font-size="20">100%</text>
    </svg>