Hey I am trying to add preloader to my website but whatever I do it won't disappear or it stays above the page or something like that. I tried a lot of things but nothing works even though I tried to copy the same code that should work.
// Attempt 1
$(document).ready(function () {
$(".loader").fadeOut("slow");
});
// Attempt 2
// setTimeout(function () {
// $(".loader").fadeToggle();
// }, 3000);
.loader {
background: #111;
width: 100%;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
position: fixed;
z-index: 1;
}
.loader div {
background: #fff;
width: 16px;
height: 32px;
margin-left: 10px;
animation: loader 1.2s infinite;
}
@keyframes loader {
50% {
height: 64px;
}
}
.loader div:nth-child(1) {
background: #ff9f1a;
animation-delay: -0.4s;
}
.loader div:nth-child(2) {
background: #fed330;
animation-delay: -0.2s;
}
.loader div:nth-child(3) {
background: #fffa65;
animation-delay: 0s;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="loader">
<div></div>
<div></div>
<div></div>
</div>
The slim version of the jQuery library doesn't have the fadeOut
function.