html
html
1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<div id="myProgress">
<div id="myBar">10%</div>
</div>
<br>
<button onclick="move()">Click Me</button>
</body>
</html>
Enter to Rename, Shift+Enter to Preview
css
css
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#myProgress {
width: 100%;
background-color: grey;
border-radius:15px;
}
#myBar {
width: 10%;
height: 20px;
background-color: #4CAF50;
border-radius:15px;
text-align: center; /* To center it horizontally (if you want) */
line-height: 20px; /* To center it vertically */
color: white;
}
Enter to Rename, Shift+Enter to Preview
js
js
1
2
3
4
5
6
7
8
9
10
11
12
13
function move() {
var elem = document.getElementById("myBar");
var width = 10;
var id = setInterval(frame, 130);
function frame() {
if (width >= 100) {
clearInterval(id);
} else {
width++;
elem.style.width = width + '%';
elem.innerHTML = width * 0.05 + 'm'; }
}
}
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run