progress bar using HTML
This code will create a simple progress bar that starts at 0% and progresses to 100% width over time. You can customize the appearance and behavior of the progress bar by modifying the CSS and JavaScript accordingly.
Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Progress Bar</title>
<style>
/* Style for the progress bar */
.progress {
width: 100%;
background-color: #f1f1f1;
}
.bar {
width: 0%;
height: 30px;
background-color: #4caf50;
text-align: center;
line-height: 30px;
color: white;
}
</style>
</head>
<body>
<h2>Progress Bar</h2>
<div class="progress">
<div class="bar" id="myBar">0%</div>
</div>
<script>
// Function to update the progress bar
function move() {
var elem = document.getElementById("myBar");
var width = 0;
var id = setInterval(frame, 10);
function frame() {
if (width >= 100) {
clearInterval(id);
} else {
width++;
elem.style.width = width + '%';
elem.innerHTML = width * 1 + '%';
}
}
}
// Call the move function to start the progress
move();
</script>
</body>
</html>
Comments
Post a Comment