响应式前端框架Bootstrap系列(13)进度条
程序员文章站
2024-02-02 11:34:16
...
进度条使用 CSS3 过渡和动画来获得该效果。Internet Explorer 9 及之前的版本和旧版的 Firefox 不支持该特性,Opera 12 不支持动画。进度条的颜色样式有以下几种:.progress-bar-success、.progress-bar-info、.progress-bar-warning、.progress-bar-danger。
演示代码:
<body>
<div class="container">
<p>默认进度条</p>
<div class="progress">
<div class="progress-bar" role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width: 40%;">
<span class="sr-only">40% 完成</span>
</div>
</div>
<p>不同色彩样式的进度条</p>
<div class="progress">
<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width: 40%;">
<span class="sr-only">40% 完成</span>
</div>
</div>
<p>条纹进度条</p>
<div class="progress progress-striped">
<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="80" aria-valuemin="0" aria-valuemax="100" style="width: 80%;">
<span class="sr-only">80% 完成</span>
</div>
</div>
<p>动态进度条</p>
<div class="progress progress-striped active">
<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="80" aria-valuemin="0" aria-valuemax="100" style="width: 80%;">
<span class="sr-only">80% 完成</span>
</div>
</div>
<p>堆叠进度条</p>
<div class="progress progress-striped active">
<div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 40%;">
<span class="sr-only">40% 完成</span>
</div>
<div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 30%;">
<span class="sr-only">30% 完成(信息)</span>
</div>
<div class="progress-bar progress-bar-warning" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 20%;">
<span class="sr-only">20% 完成(警告)</span>
</div>
</div>
<p>进度条Deom</p>
<div class="progress progress-striped active">
<div id="progress" class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%;">
<span class="sr-only">0% 完成</span>
</div>
</div>
</div>
</body>
<script>
var num = 0;
var timeID = setInterval(function() {
$("#progress").css("width", num + "%")
if(num >= 100) {
clearInterval(timeID);
} else {
num += 1;
}
}, 100);
</script>
效果图: