Bootstrap教程 各种进度条实例

跨浏览器兼容性

进度条组件使用了 CSS3 的 transition 和 animation 属性来完成一些特效。这些特性在 Internet Explorer 9 或以下版本中、Firefox 的老版本中没有被支持。Opera 12 不支持 animation 属性。

基本实例

默认样式的进度条

实例:

60% Complete
  1.   <div class="progress">
  2.   <div class="progress-bar" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 60%;">
  3.     <span class="sr-only">60% Complete</span>
  4.   </div>
  5. </div>

带有提示标签的进度条

将设置了 .sr-only 类的 标签从进度条组件中移除 类,从而让当前进度显示出来。

实例:

60%
  1. <div class="progress">
  2.   <div class="progress-bar" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 60%;">
  3.     60%
  4.   </div>
  5. </div>

在展示很低的百分比时,如果需要让文本提示能够清晰可见,可以为进度条设置 min-width 属性。

实例:

0%
2%
  1.  <div class="progress">
  2.   <div class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="min-width: 2em;">
  3.     0%
  4.   </div>
  5. </div>
  6. <div class="progress">
  7.   <div class="progress-bar" role="progressbar" aria-valuenow="2" aria-valuemin="0" aria-valuemax="100" style="min-width: 2em; width: 2%;">
  8.     2%
  9.   </div>
  10. </div>

根据情境变化效果

进度条组件使用与按钮和警告框相同的类,根据不同情境展现相应的效果。

实例:

40% Complete (success)
20% Complete
60% Complete (warning)
80% Complete (danger)
  1.   <div class="progress">
  2.   <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width: 40%">
  3.     <span class="sr-only">40% Complete (success)</span>
  4.   </div>
  5. </div>
  6. <div class="progress">
  7.   <div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100" style="width: 20%">
  8.     <span class="sr-only">20% Complete</span>
  9.   </div>
  10. </div>
  11. <div class="progress">
  12.   <div class="progress-bar progress-bar-warning" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 60%">
  13.     <span class="sr-only">60% Complete (warning)</span>
  14.   </div>
  15. </div>
  16. <div class="progress">
  17.   <div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="80" aria-valuemin="0" aria-valuemax="100" style="width: 80%">
  18.     <span class="sr-only">80% Complete (danger)</span>
  19.   </div>
  20. </div>

条纹效果

通过渐变可以为进度条创建条纹效果,IE9 及更低版本不支持。

实例:

40% Complete (success)
20% Complete
60% Complete (warning)
80% Complete (danger)
  1.   <div class="progress">
  2.   <div class="progress-bar progress-bar-success progress-bar-striped" role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width: 40%">
  3.     <span class="sr-only">40% Complete (success)</span>
  4.   </div>
  5. </div>
  6. <div class="progress">
  7.   <div class="progress-bar progress-bar-info progress-bar-striped" role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100" style="width: 20%">
  8.     <span class="sr-only">20% Complete</span>
  9.   </div>
  10. </div>
  11. <div class="progress">
  12.   <div class="progress-bar progress-bar-warning progress-bar-striped" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 60%">
  13.     <span class="sr-only">60% Complete (warning)</span>
  14.   </div>
  15. </div>
  16. <div class="progress">
  17.   <div class="progress-bar progress-bar-danger progress-bar-striped" role="progressbar" aria-valuenow="80" aria-valuemin="0" aria-valuemax="100" style="width: 80%">
  18.     <span class="sr-only">80% Complete (danger)</span>
  19.   </div>
  20. </div>

动画效果

为 .progress-bar-striped 添加 .active 类,使其呈现出由右向左运动的动画效果。IE9 及更低版本的浏览器不支持。

实例:

45% Complete
  1.    <div class="progress">
  2.   <div class="progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="45" aria-valuemin="0" aria-valuemax="100" style="width: 45%">
  3.     <span class="sr-only">45% Complete</span>
  4.   </div>
  5. </div>

堆叠效果

把多个进度条放入同一个 .progress 中,使它们呈现堆叠的效果。

实例:

35% Complete (success)
20% Complete (warning)
10% Complete (danger)
  1.  <div class="progress">
  2.   <div class="progress-bar progress-bar-success" style="width: 35%">
  3.     <span class="sr-only">35% Complete (success)</span>
  4.   </div>
  5.   <div class="progress-bar progress-bar-warning progress-bar-striped" style="width: 20%">
  6.     <span class="sr-only">20% Complete (warning)</span>
  7.   </div>
  8.   <div class="progress-bar progress-bar-danger" style="width: 10%">
  9.     <span class="sr-only">10% Complete (danger)</span>
  10.   </div>
  11. </div>

发布日期:

所属分类: BootStrap 标签:


没有相关文章!