<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<title>Bootstrap 4 进度条</title>
</head>
<body>
<div class="container mt-4">
<h2>进度条示例</h2>
<!-- 基本进度条 -->
<div class="progress">
<div class="progress-bar" role="progressbar" style="width: 50%;" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100">50%</div>
</div>
<!-- 带有标签的进度条 -->
<div class="progress mt-3">
<div class="progress-bar" role="progressbar" style="width: 30%;" aria-valuenow="30" aria-valuemin="0" aria-valuemax="100">30%</div>
</div>
<!-- 多个进度条 -->
<div class="progress mt-3">
<div class="progress-bar" role="progressbar" style="width: 40%;" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100">40%</div>
<div class="progress-bar bg-success" role="progressbar" style="width: 60%;" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100">60%</div>
</div>
</div>
<!-- Bootstrap JavaScript 和 jQuery(可选)-->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
</body>
</html>
在这个例子中,我们使用了progress类来创建进度条容器,然后使用progress-bar类来定义进度条本身。你可以通过style属性设置进度的宽度,也可以通过aria-valuenow、aria-valuemin和aria-valuemax属性来设置进度条的值范围。你还可以使用不同的颜色类(如bg-success)来定制进度条的外观。
转载请注明出处:http://www.zyzy.cn/article/detail/5492/Bootstrap