Bootstrap 进度条

2018-03-18 17:25 更新

进度条显示冗长操作的进度,例如文件加载,重定向。

以下示例显示如何使用垂直渐变创建简单的进度条。

<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<style type="text/css">
    .bs-example{
      margin: 20px;
    }
</style>
</head> 
<body>
<div class="bs-example">
    <div class="progress">
        <div class="progress-bar" style="width: 60%;">
            <span class="sr-only">60% Complete</span>
        </div>
    </div>
</div>
</body>
</html>

条纹进度条

要创建条纹进度条,请将类.progress-striped添加到.progress基类。

IE7-8不支持条纹进度条。

<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<style type="text/css">
    .bs-example{
      margin: 20px;
    }
</style>
</head> 
<body>
<div class="bs-example">
  <div class="progress progress-striped">
    <div class="progress-bar" style="width: 60%;">
      <span class="sr-only">60% Complete</span>
    </div>
  </div>
</div>
</body>
</html>

动画进度条

要创建动画进度条,请将.active类添加到.progress-stripped。

.active类从右到左对条纹进行动画处理。

在IE7,IE7,IE9中不支持动画进度条。

<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<style type="text/css">
    .bs-example{
      margin: 20px;
    }
</style>
</head> 
<body>
<div class="bs-example">
  <div class="progress progress-striped active">
    <div class="progress-bar" style="width: 60%;">
      <span class="sr-only">60% Complete</span>
    </div>
  </div>
</div>
</body>
</html>

堆叠进度条

以下代码显示如何将多个进度条放在同一进度条中以将其堆叠。

<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap-theme.min.css">
<style type="text/css">
    .bs-example{
      margin: 20px;
    }
</style>
</head> 
<body>
<div class="bs-example">
  <div class="progress">
    <div class="progress-bar progress-bar-success" style="width: 35%">
      <span class="sr-only">35% Complete (success)</span>
    </div>
    <div class="progress-bar progress-bar-warning" style="width: 20%">
      <span class="sr-only">20% Complete (warning)</span>
    </div>
    <div class="progress-bar progress-bar-danger" style="width: 10%">
      <span class="sr-only">10% Complete (danger)</span>
    </div>
  </div>
</div>
</body>
</html>

有意义的类的进度条

我们可以自定义进度条用各种颜色。

<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap-theme.min.css">
<style type="text/css">
    .bs-example{
      margin: 20px;
    }
</style>
</head> 
<body>
<div class="bs-example">
  <div class="progress">
    <div class="progress-bar progress-bar-info" style="width: 20%">
      <span class="sr-only">20% Complete</span>
    </div>
  </div>
  <div class="progress">
    <div class="progress-bar progress-bar-success" style="width: 40%">
      <span class="sr-only">40% Complete</span>
    </div>
  </div>
  <div class="progress">
    <div class="progress-bar progress-bar-warning" style="width: 60%">
      <span class="sr-only">60% Complete</span>
    </div>
  </div>
  <div class="progress">
    <div class="progress-bar progress-bar-danger" style="width: 80%">
      <span class="sr-only">80% Complete</span>
    </div>
  </div>
</div>
</body>
</html>

有强调的类的进度条

以下代码显示如何使用各种颜色对进度条进行条纹化。

<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap-theme.min.css">
<style type="text/css">
    .bs-example{
      margin: 20px;
    }
</style>
</head> 
<body>
<div class="bs-example">
    <div class="progress progress-striped">
        <div class="progress-bar progress-bar-info" style="width: 20%">
            <span class="sr-only">20% Complete</span>
        </div>
    </div>
    <div class="progress progress-striped">
        <div class="progress-bar progress-bar-success" style="width: 40%">
            <span class="sr-only">40% Complete</span>
        </div>
    </div>
    <div class="progress progress-striped">
        <div class="progress-bar progress-bar-warning" style="width: 60%">
            <span class="sr-only">60% Complete</span>
        </div>
    </div>
    <div class="progress progress-striped">
        <div class="progress-bar progress-bar-danger" style="width: 80%">
            <span class="sr-only">80% Complete</span>
        </div>
    </div>
</div>
</body>
</html>
以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号