圆形边框进度条
Circle border progress bar
如何使用 CSS 创建这个循环进度条是否可能(兼容 IE10+、FF、chrome、safari...)?
我想我们可以为此使用 SVG,但我不知道该怎么做。
圆圈周围有一个小边框或阴影,会根据进度百分比动态变化。如果百分比为100%,边框将完全围绕填充进度条的圆圈。
这个圆形进度条改编自这个答案:
它使用 SVG 和 Snap.svg 为蓝色笔触设置动画,并使用 JS 为计数器设置动画:
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>
我觉得那个网站 : 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])
如何使用 CSS 创建这个循环进度条是否可能(兼容 IE10+、FF、chrome、safari...)?
我想我们可以为此使用 SVG,但我不知道该怎么做。
圆圈周围有一个小边框或阴影,会根据进度百分比动态变化。如果百分比为100%,边框将完全围绕填充进度条的圆圈。
这个圆形进度条改编自这个答案:
它使用 SVG 和 Snap.svg 为蓝色笔触设置动画,并使用 JS 为计数器设置动画:
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>
我觉得那个网站 : 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])