JSFiddle - React, Tailwind, and code Playground
by Roberts
HTML
<!DOCTYPE html>
<html>
<style>
#progress {
width: 100%;
background-color: #ddd;
}
#bar {
width: 0%;
height: 4px;
background-color: #4CAF50;
text-align: center;
line-height: 30px;
color: white;
transition: all 1500ms linear;
}
</style>
<body onload="move();">
<h1>JavaScript Progress Bar</h1>
<div id="progress"><div id="bar"></div></div>
<br>
<button onclick="move()">Click Me</button>
<script>
function move() {
var elem = document.getElementById("bar");
var width = 0;
var id = setInterval(frame, 1000);
function frame() {
if (width >= 100) {
clearInterval(id);
} else {
width++;
elem.style.width = width + '%';
}
}
}
</script>
</body>
</html>
CSS
button {
animation: arrow;
animation-duration: 1s;
animation-timing-function: ease-in-out;
animation-iteration-count: infinite;
}
@-webkit-keyframes button
{
0% { transform: translate(0, 0); }
50% { transform: translate(0, -.5em); }
100% { transform: translate(0, 0); }
}