7-12 进度条--层叠进度条
本节编程练习不计算学习进度,请电脑登录imooc.com操作

进度条--层叠进度条

Bootstrap框架除了提供上述几种进度条之外,还提供了一种层叠进度条,层叠进度条,可以将不同状态的进度条放置在一起,按水平方式排列。具体使用如下:

<div class="progress">
    <div class="progress-bar progress-bar-success" style="width:20%"></div>
    <div class="progress-bar progress-bar-info" style="width:10%"></div>
    <div class="progress-bar progress-bar-warning" style="width:30%"></div>
    <div class="progress-bar progress-bar-danger" style="width:15%"></div>
</div>

运行效果如下:

或许你会感到疑问,没有为层叠进度条添加额外的样式代码,怎么就正常了呢?可以回过头来看基本进度条那部分,不难发现,在“progress-bar”上有一个左浮动的样式。也就是这个样式,在不增加任何样式代码就能实现上例的层叠效果。当然有一点需要注意,层叠进度条宽度之和不能大于100%,大于100%就会造成下面的不良效果(见右侧代码编辑器):

除了层叠彩色进度条之外,还可以层叠条纹进度条,或者说条纹进度条和彩色进度条混合层叠,仅需要在“progress”容器中添加对应的进度条,同样要注意,层叠的进度条之和不能大于100%。来简单的看一个示例:

<div class="progress">
    <div class="progress-bar progress-bar-success" style="width:20%"></div>
    <div class="progress-bar progress-bar-info" style="width:20%"></div>
    <div class="progress-bar progress-bar-warning" style="width:30%"></div>
    <div class="progress-bar progress-bar-danger" style="width:15%"></div>
</div>
<div class="progress">
    <div class="progress-bar progress-bar-success progress-bar-striped" style="width:20%"></div>
    <div class="progress-bar progress-bar-info progress-bar-striped" style="width:20%"></div>
    <div class="progress-bar progress-bar-striped progress-bar-warning" style="width:30%"></div>
    <div class="progress-bar progress-bar-danger progress-bar-striped" style="width:15%"></div>
</div>
<div class="progress">
    <div class="progress-bar progress-bar-success" style="width:20%"></div>
    <div class="progress-bar progress-bar-info progress-bar-striped" style="width:20%"></div>
    <div class="progress-bar progress-bar-warning" style="width:30%"></div>
    <div class="progress-bar progress-bar-danger progress-bar-striped" style="width:15%"></div>
</div>

运行效果如下:

任务

本小节没有任务,单击“提交”按钮进行下一个小节学习。
 

  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <title>进度条--层叠进度条</title>
  6. <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
  7. </head>
  8. <body>
  9. <h5>正常层叠进度条</h5>
  10. <div class="progress">
  11. <div class="progress-bar progress-bar-success" style="width:20%"></div>
  12. <div class="progress-bar progress-bar-info" style="width:10%"></div>
  13. <div class="progress-bar progress-bar-warning" style="width:30%"></div>
  14. <div class="progress-bar progress-bar-danger" style="width:15%"></div>
  15. </div>
  16. <h5>不良效果层叠进度条</h5>
  17. <div class="progress">
  18. <div class="progress-bar progress-bar-success" style="width:20%"></div>
  19. <div class="progress-bar progress-bar-info" style="width:40%"></div>
  20. <div class="progress-bar progress-bar-warning" style="width:30%"></div>
  21. <div class="progress-bar progress-bar-danger" style="width:45%"></div>
  22. </div>
  23. <h5>层叠条纹进度条</h5>
  24. <div class="progress">
  25. <div class="progress-bar progress-bar-success" style="width:20%"></div>
  26. <div class="progress-bar progress-bar-info" style="width:20%"></div>
  27. <div class="progress-bar progress-bar-warning" style="width:30%"></div>
  28. <div class="progress-bar progress-bar-danger" style="width:15%"></div>
  29. </div>
  30. <div class="progress">
  31. <div class="progress-bar progress-bar-success progress-bar-striped" style="width:20%"></div>
  32. <div class="progress-bar progress-bar-info progress-bar-striped" style="width:20%"></div>
  33. <div class="progress-bar progress-bar-striped progress-bar-warning" style="width:30%"></div>
  34. <div class="progress-bar progress-bar-danger progress-bar-striped" style="width:15%"></div>
  35. </div>
  36. <div class="progress">
  37. <div class="progress-bar progress-bar-success" style="width:20%"></div>
  38. <div class="progress-bar progress-bar-info progress-bar-striped" style="width:20%"></div>
  39. <div class="progress-bar progress-bar-warning" style="width:30%"></div>
  40. <div class="progress-bar progress-bar-danger progress-bar-striped" style="width:15%"></div>
  41. </div>
  42. <br/>
  43. <br/>
  44.  
  45.  
  46. <script src="https://www.imooc.com/static/lib/jquery/1.9.1/jquery.js"></script>
  47. <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
  48. </body>
  49. </html>
  1. body {
  2. padding:30px 100px;
  3. }
下一节