Answer the question
In order to leave comments, you need to log in
How to preload images for css animation easier?
To avoid asynchrony when starting a whole animation, I use the js preload method of graphiconium. After the images are fully loaded, I change the class of the main divac className=animate
<div id="wrapper">
<div class="bg_main1"></div>
<div class="bg_main2"></div>
</div>
.bg_main1 {
opacity: 0;
background-image: url('bg1.jpg');
}
.bg_main2 {
opacity: 0;
background-image: url('bg2.jpg');
}
.animate {
.bg_main1 {
animation: bg_main1 3s linear 0s 1;
@keyframes bg_main1 {
0% { opacity: 0 }
100% { opacity: 1 }
}
}
.bg_main2 {
animation: bg_main2 3s linear 0s 1;
@keyframes bg_main2 {
0% { opacity: 0 }
100% { opacity: 1 }
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question