Fallback: in case an image is not missing but has a delay for some reason and is starting the download later then the 6 sec (!) after the page start, there is something really wrong at the server or in the coding, but no problem. As soon as the image is downloaded, it will cover the "seems missing" message: it just seemed, but that appeared not to be true. Everybody happy, if the visitor hasn't left the page... .
<div class="imgBox">
<div class="spinner"></div>
<img src="images/..." alt="...">
</div>
<script> /* none */ <script>
.imgBox {
/* as before, added: */
min-height: 120px;
}
.imgBox:before {
position: absolute;
top: 1%;
left: 0;
right: 0;
content: "... Heavy searching ...";
font-size: 1.3em;
color: #FF4040;
text-align: center;
z-index: -1;
opacity: 0;
animation:
1s 2s spinnerFadeIn ease-in-out
forwards,
1s 4s spinnerFadeOut ease-in-out
forwards;
}
@keyframes spinnerFadeIn {
0% {opacity: 0}
100% {opacity: 1}
}
@keyframes spinnerFadeOut {
0% {opacity: 1}
100% {opacity: 0}
}
.imgBox:after {
position: absolute;
top: 15%;
margin-top: 1em;
left: 0;
right: 0;
content: "Oops, it seems this image is missing ...";
text-align: center;
color: #404404;
z-index: -1;
opacity: 0;
animation:
3s 6s spinnerFadeIn ease-in-out
forwards;
}
.imgBox img { /* as before, added: */
opacity: 0;
animation:
.5s spinnerFadeIn ease-in-out
forwards;
}
body { /* as customized, added: */
opacity: 0;
animation:
.75s spinnerFadeIn ease-in-out
forwards;
}