加载资源进度条实现很简单,特别是在使用Bootstrap之后。
代码如下:
<!DOCTYPE html>
<html>
<head>
<title>Bootstrap 实例</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.1.0/css/bootstrap.min.css">
<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/popper.js/1.12.5/umd/popper.min.js"></script>
<script src="https://cdn.bootcss.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<script>
var length=10;
setInterval(
function(){
$("#loading_length").attr("style","width:"+length+"%");
length+=5;
},100
);
</script>
</head>
<body>
<div class="container" style="padding-top:50px;">
<div class="progress"style="height:60px">
<div id="loading_length" class="progress-bar progress-bar-striped progress-bar-animated" style="width:0%"></div>
</div>
</div>
</body>
</html>
效果如下: