如何在运行时更改引导(twitter)进度条的颜色 [英] How to change the color of a bootstrap (twitter) progress bar at runtime
本文介绍了如何在运行时更改引导(twitter)进度条的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用此进度栏:
http ://twitter.github.com/bootstrap/components.html#progress
并想给它一个自定义颜色,只在运行时知道
(因此在css或更少的文件中对其进行硬编码不是一个选项)
And would like to give it a custom color, known only at runtime (so hardcoding it in the css or less file is not an option)
我尝试过:
<div class="progress">
<div id='pb' class="bar" style="width: 80%"></div>
</div>
<script>
$('#pb').css({'background-color': "red"})
</script>
未成功。
推荐答案
您的代码实际上是工作,只是进度条实际上使用渐变作为颜色,而不是一个固体 background-color
属性。要更改背景颜色,请将 background-image
设置为 none
,您的颜色将被选中: / p>
Your code is actually working, just that the progress bar is actually using a gradient as a color instead of a solid background-color
property. In order to change the background color, set the background-image
to none
and your color will be picked up:
$('#pb').css({
'background-image': 'none',
'background-color': 'red'
});
这篇关于如何在运行时更改引导(twitter)进度条的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文