-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path进度条.html
41 lines (40 loc) · 970 Bytes
/
进度条.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>进度条</title>
<style>
#progress-bar {
width: 100%;
height: 10px;
background: gainsboro
}
#progress-slot {
transition: all 0.5s;
background: red;
height:100%;
}
</style>
</head>
<body>
<div id="progress-bar">
<div id="progress-slot"></div>
</div>
<script>
let timer = 0;
function start() {
const dom = document.getElementById('progress-slot')
let width = 0;
timer = setInterval(() => {
width +=1;
dom.style.width = width + '%'
if (width >= 100) {
clearInterval(timer)
}
}, 150)
}
start()
</script>
</body>
</html>