javascript - 进度条描边颜色

标签 javascript jquery html css

我有一个根据百分比具有不同笔触颜色的进度。现在我想让整个进度条笔触的笔触颜色不同于百分比。

这是 fiddle我希望另外 50% 是红色的,另一个是橙色的。我似乎找不到如何在上面添加颜色。

HTML:

<div id="container"></div>
<div id="container1"></div>

CSS:

#container, #container1 {
    width: 100px;
    height: 100px;
}

#container > svg, #container1 > svg {
    width: 100%;
    display: block;
}

JS:

var circle = new ProgressBar.Circle('#container', {
    color: '#FCB03C',
    strokeWidth: 5,
    trailWidth: 1,
    duration: 1500,
    text: {
        value: '0'
    },
    step: function(state, bar) {
        bar.setText((bar.value() * 100).toFixed(0));
    }
});

circle.animate(.5);  // Number from 0.0 to 1.0


var circle = new ProgressBar.Circle('#container1', {
    color: '#FCB03C',
    strokeWidth: 5,
    trailWidth: 1,
    duration: 1500,
    text: {
        value: '0'
    },
    step: function(state, bar) {
        bar.setText((bar.value() * 100).toFixed(0));
    }
});

circle.animate(.7);  // Number from 0.0 to 1.0

在 fiddle 上 here .是否可能在第二个圆圈上有一个与橙色动画相同的蓝色动画?而不是瞬间出现

最佳答案

试试这个:-

var circle = new ProgressBar.Circle('#container', {
color: '#FCB03C',
strokeWidth: 5,
trailWidth: 1,    
text: {
    value: '0'
},
step: function(state, bar) {
    bar.setText((bar.value() * 100).toFixed(0));       
 }
});
 circle.animate(.5,function(){
  $('#container path:first-child').attr('stroke','#4679BD').attr('stroke-width',5);
 });  

Demo

关于javascript - 进度条描边颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30634758/

相关文章:

jquery - Slick Slider JS + 修复了标题重叠问题 - 仅在 Chrome 中

javascript - 使用 Jquery 设置单选按钮值(多于一个单词/包含空格)

php - 在 html 中单击提交并运行 php 代码

javascript - 将两个请求集成到一个 Javascript 中

javascript - 具有旋转代理的 Phantomjs/Casperjs?

jquery - 如何有条件地将 jQuery Sortable UI 小部件应用到表(ASP.NET GridView)?

javascript - 如何在特定的 div 中显示时间(由 JavaScript 生成)?

javascript - 带有附加条件的 Angular 脏污检查

javascript - 如何复用XMLHttpRequest?

javascript - 向 ServiceStack RESTful 服务发送数据,得到 'Access is denied'