TrynaLearnJS
Coder
so I have a js loading animation with a progress bar that I want to show on page load. I put this under the JS section because I assume js is needed for this to work. If the page loads quicker than the 1s animation, then I want it to hide everything else and play the animation, then show content of the page. I built a sample loading animation for testing. Thank you!
HTML:
<!DOCTYPE html>
<html>
<head>
<style>
#container {
height:50vw;
width:100%;
}
#progress-bar-container {
justify-self: center;
height:30px;
width:300px;
border:2px solid gray;
}
#progress-bar {
animation: webpage-loading 1s forwards;;
animation-duration: 1s;
justify-self: left;
width:10px;
height:30px;
background-color:black;
}
@keyframes webpage-loading {
0% {width:10px}
30% {width:90px}
45% {width:150px}
60% {width:190px}
75% {width:230px}
100% {width:300px}
}
#progress-percentage {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-weight: bold;
}
</style>
</head>
<body>
<div id="container">
<div id="progress-bar-container">
<div id="progress-bar">
</div>
</div>
</div>
</body>
</html>