圆边框进度条

时间:2017-01-11 08:36:07

标签: css html5 css3 svg css-shapes

如何用CSS创建这个圆形进度条甚至可以(兼容IE10 +,FF,chrome,safari ......)?
我想我们可以使用SVG,但我不知道如何做到这一点。

在圆圈周围,有一个小的边框或阴影,根据进度百分比动态变化。如果百分比为100%,则边框将完全围绕填充进度条的圆圈。

circle progress bar with a border to show progress

2 个答案:

答案 0 :(得分:3)

这个圈子进度条是根据以下答案进行调整的:circular progress bar

它使用带有Snap.svg的SVG为蓝色笔划设置动画,为计数器使用JS:

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:30%;}

<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>
&#13;
&#13;
&#13;

答案 1 :(得分:-1)

我认为该网站:https://medium.com/@andsens/radial-progress-indicator-using-css-a917b80c43f9#.2fflbvwrt可以帮助您

你可以在这里查看演示:http://jsfiddle.net/andsens/Yns9P/在这一行:

window.randomize = function() {
    $('.radial-progress').attr('data-progress', Math.floor(Math.random() * 100));
}

您可以将attr('data-progress', Math.floor(Math.random() * 100))更改为attr('data-progress', [your_pourcentage])