Native Javascript Loading effect
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<style>
body {
height: 200;
overflow: hidden;
background-color: #696969;
font-family: 'Roboto', 'Courier New', monospace;
}
.flex {
display: flex;
justify-content: center;
align-items: center;
height: 150px;
}
img {
height: 100px;
}
.center {
text-align: center;
}
.white {
color: white;
}
.bold {
font-weight: bold;
}
p {
min-width: 110px;
}
#loading {
text-align: right;
width: 75px;
display: inline-block;
}
#loadingValue {
text-align: left;
width: 35px;
display: inline-block;
}
</style>
<script>
function main() {
const el = document.getElementById('loadingValue');
el.innerHTML = '.';
setInterval(() => {
if (el.innerHTML.length + 1 <= 3) el.innerHTML += '.';
else el.innerHTML = '';
}, 1000);
}
</script>
</head>
<body onload="main()">
<div class="flex">
<img src="/icon.png" alt="Logo" height="150" />
</div>
<div>
<p class="center">
<span class="white bold" id="loading">Loading</span>
<span id="loadingValue"></span>
</p>
</div>
</body>
</html>
I ain't a frontend developer, like at all. so if the CSS is disgusting... Sorry :/
This html code generates something like this
It loops 3 times and resets the string every 3 iterations.
It waits 1 second to print the next character