'How to make website loading screen last long enough for users to experience it
I'm trying to get users to actually see the loading screen that i have worked on. I would like it to last around 3-5 seconds JQuery is fine because its already in use and heres the code and a I really don't know much Jquery so thats why im asking you guys any fix would help another note that this is going on a bakery website (Don't really know why you would need to know but yeah.) pic,

<div class="center">
<div class="wave"></div>
<div class="wave"></div>
<div class="wave"></div>
<div class="wave"></div>
<div class="wave"></div>
<div class="wave"></div>
<div class="wave"></div>
<div class="wave"></div>
<div class="wave"></div>
<div class="wave"></div>
</div>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(window).on("load",function(){
$(".wave").fadeOut("slow");
$(".center").fadeOut("slow");
});
</script>
<style>
.content{
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
}
.bodY {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.center {
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background: #000;
}
.wave {
width: 5px;
height: 100px;
background: linear-gradient(45deg, cyan, #fff);
margin: 10px;
animation: wave 1s linear infinite;
border-radius: 20px;
}
.wave:nth-child(2) {
animation-delay: 0.1s;
}
.wave:nth-child(3) {
animation-delay: 0.2s;
}
.wave:nth-child(4) {
animation-delay: 0.3s;
}
.wave:nth-child(5) {
animation-delay: 0.4s;
}
.wave:nth-child(6) {
animation-delay: 0.5s;
}
.wave:nth-child(7) {
animation-delay: 0.6s;
}
.wave:nth-child(8) {
animation-delay: 0.7s;
}
.wave:nth-child(9) {
animation-delay: 0.8s;
}
.wave:nth-child(10) {
animation-delay: 0.9s;
}
@keyframes wave {
0% {
transform: scale(0);
}
50% {
transform: scale(1);
}
100% {
transform: scale(0);
}
}
</style>
I haven't really tried everything because yet again i don't know much Jquery but i'll pick out the Jquery part,
$(window).on("load",function(){
$(".wave").fadeOut("slow");
$(".center").fadeOut("slow");
});
Solution 1:[1]
You could use the animate function:
(selector).animate({styles},speed,easing,callback)
The other solution is to use use your fade out code, but with set timeout function:
setTimeout(fadeOut, 5000);
function fadeOut(){
$(".wave").fadeOut("slow");
$(".center").fadeOut("slow");
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Dan Friedman |
