【发布时间】:2022-01-02 10:13:20
【问题描述】:
有谁知道设置预加载器可以显示的最长时间的方法吗?如果有人连接速度很慢,让预加载器在几秒钟后消失会很有用,这样它就不会永远显示。 这是我目前用于预加载器的代码。
// makes sure the whole site is loaded
jQuery(window).load(function () {
"use strict";
// will first fade out the loading animation
if( jQuery( '.et-bfb' ).length <= 0 && jQuery( '.et-fb' ).length <= 0 ){
jQuery(".status").fadeOut();
// will fade out the whole DIV that covers the website.
jQuery(".preloader").delay(1000).fadeOut("slow");
}else{
jQuery(".preloader").css('display','none');
}
});
.preloader {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #fefefe;
z-index: 100000;
height: 100%;
width: 100%;
overflow: hidden !important;
}
.preloader .status {
width: 100px;
height: 100px;
position: absolute;
left: 50%;
top: 50%;
background-image: url(http://monticellomansion.com/wp-content/uploads/2021/04/dbf29347459a27eb6736f2164539440e.gif);
background-repeat: no-repeat;
background-position: center;
-webkit-background-size: cover;
background-size: cover;
margin: -50px 0 0 -50px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="preloader">
<div class="status"></div>
</div>
【问题讨论】:
-
你看到我的回答了吗?
-
@SKJ 是的,我现在确实看到了答案,请参阅下面我对该答案的回复。
标签: javascript jquery css time preloader