基本的进度条
进度条可以用来显示用户走多远,他/她是一个过程。
Bootstrap提供了几种类型的进度条。
在默认的进度条Bootstrap看起来是这样的:
要创建一个默认的进度条,加.progress
类到<div>
元素:
例
<div class="progress">
<div class="progress-bar" role="progressbar"
aria-valuenow="70"
aria-valuemin="0" aria-valuemax="100"
style="width:70%">
<span class="sr-only">70%
Complete</span>
</div>
</div>
试一试» 注:进度条无法在Internet Explorer 9和更早版本支持(因为它们使用CSS3过渡和动画来实现他们的一些影响)。
注意:为了帮助改善辅助功能使用屏幕阅读器的人,你应该包括aria-*属性。
进度条带有标签
带有标签的进度条是这样的:
删除.sr-only
从进度条类来说明一个可见的百分比:
例
<div class="progress">
<div class="progress-bar" role="progressbar"
aria-valuenow="70"
aria-valuemin="0" aria-valuemax="100"
style="width:70%">
70%
</div>
</div>
试一试» 彩色进度条
上下文类用于提供“通过颜色的意思。”
可与进度条使用的上下文类是:
-
.progress-bar-success
-
.progress-bar-info
-
.progress-bar-warning
-
.progress-bar-danger
下面的示例演示了如何使用不同的上下文类创建进度条:
例
<div class="progress">
<div class="progress-bar
progress-bar-success" role="progressbar" aria-valuenow="40"
aria-valuemin="0"
aria-valuemax="100" style="width:40%">
40% Complete
(success)
</div>
</div>
<div class="progress">
<div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="50"
aria-valuemin="0" aria-valuemax="100" style="width:50%">
50% Complete (info)
</div>
</div>
<div class="progress">
<div class="progress-bar progress-bar-warning" role="progressbar" aria-valuenow="60"
aria-valuemin="0" aria-valuemax="100" style="width:60%">
60% Complete (warning)
</div>
</div>
<div
class="progress">
<div class="progress-bar progress-bar-danger"
role="progressbar" aria-valuenow="70"
aria-valuemin="0" aria-valuemax="100"
style="width:70%">
70% Complete (danger)
</div>
</div>
试一试» 条纹进度条
进度条也可以条纹:
添加类.progress-bar-striped
,以条纹添加到进度条:
例
<div class="progress">
<div class="progress-bar
progress-bar-success progress-bar-striped" role="progressbar"
aria-valuenow="40" aria-valuemin="0"
aria-valuemax="100" style="width:40%">
40% Complete
(success)
</div>
</div>
<div class="progress">
<div class="progress-bar progress-bar-info progress-bar-striped" role="progressbar"
aria-valuenow="50"
aria-valuemin="0" aria-valuemax="100" style="width:50%">
50% Complete (info)
</div>
</div>
<div class="progress">
<div class="progress-bar progress-bar-warning progress-bar-striped" role="progressbar"
aria-valuenow="60"
aria-valuemin="0" aria-valuemax="100" style="width:60%">
60% Complete (warning)
</div>
</div>
<div
class="progress">
<div class="progress-bar progress-bar-danger
progress-bar-striped"
role="progressbar"
aria-valuenow="70" aria-valuemin="0" aria-valuemax="100"
style="width:70%">
70% Complete (danger)
</div>
</div>
试一试» 动画进度条
下面是一个"animated"进度条:
添加类.active
动画进度条:
例
<div class="progress">
<div class="progress-bar
progress-bar-striped active" role="progressbar"
aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width:40%">
40%
</div>
</div>
试一试» 堆积进度条
进度条也可堆叠:
通过将多条到同一建立堆叠的进度条<div class="progress">
:
例
<div class="progress">
<div class="progress-bar
progress-bar-success" role="progressbar" style="width:40%">
Free Space
</div>
<div class="progress-bar
progress-bar-warning" role="progressbar" style="width:10%">
Warning
</div>
<div class="progress-bar
progress-bar-danger" role="progressbar" style="width:20%">
Danger
</div>
</div>
试一试»