I have made a full screen Preloader counter. And I need all my body elements to be hidden while the Preloader loads, and when it finishes, the other body elements such as navbar and sections, can be appeared on screen.
Here is my html code:
<body>
<section class="preloader">
<div class="loader"></div>
<div class="count"></div>
</section>
<header>
...
</header>
<div id="fullpage">
...
</div>
</body>
And this is the CSS of preloader:
.loader{
height: 100%;
background: #000;
position: absolute;
top:0;
left:0;
}
.preloader{
position:absolute;
top:0;
left:0;
width:100%;
height:100vh;
background:#fff;
pointer-events: none;
animation:fadeout 0.5s linear forwards;
animation-delay:8.5s;
}
@keyframes fadeout
{
0%
{
opacity:1;
}
100%
{
opacity:0;
}
}
.count{
position:absolute;
top:50%;
left:50%;
transform:translate(-50%,-50%);
font-size:18vw;
color:#fff;
font-weight: 800;
mix-blend-mode: difference;
text-align:right;
}
And this also the jQuery part of Preloader:
$(document).ready(function(){
count = 0;
counter = setInterval(function(){
if(count < 101){
$('.count').text(count + '%');
$('.loader').css('width', count + '%');
count++
}
else{
clearInterval(counter)
}
}, 80)
});
So how can I hide all body elements until the Preloader finishes its progress?