javascript - Preloader在线不淡出

标签 javascript jquery html css preloader

我已经尝试创建一个在本地机器上完美运行的预加载器。但是,在在线托管内容时,预加载器永远不会消失。请帮忙。以下是基本要素:CSS、JS、Body

#loader  {
 position: absolute;
 top: 0;
 left: 0;
 right: 0;
 bottom: 0;
 background-color: #0f2338;
 z-index: 99;
height: 100%;
}
#status  {
 width: 200px;
 height: 200px;
 position: absolute;
 left: 50%;
 top: 50%;
 background-image: url("../png/Ball.gif");
 background-repeat: no-repeat;
 background-position: center;
 margin: -100px 0 0 -100px;
}

<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
script type="text/javascript">
  <script type="text/javascript">
$(window).load(function() { 
$("#status").fadeOut("slow"); 
$("#loader").delay(500).fadeOut();
});

</script>
<body>
<div id="loader">
<div id="status"></div>
</div>

最佳答案

这是您的代码有效的代码片段。如果您的站点是安全的,请确保您通过 https 请求 jquery,在这种情况下使用 HTTPS 来引用 jquery 而不是 HTTP

https://code.jquery.com/jquery-1.9.1.min.js

$(window).load(function() { 
$("#status").fadeOut("slow"); 
$("#loader").delay(500).fadeOut();
});
#loader  {
 position: absolute;
 top: 0;
 left: 0;
 right: 0;
 bottom: 0;
 background-color: #0f2338;
 z-index: 99;
height: 100%;
}
#status  {
 width: 200px;
 height: 200px;
 position: absolute;
 left: 50%;
 top: 50%;
 background-image: url("https://www.google.ca/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png");
 background-repeat: no-repeat;
 background-position: center;
 margin: -100px 0 0 -100px;
}
<script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>

<body>
<div id="loader">
<div id="status"></div>
</div>

关于javascript - Preloader在线不淡出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45442664/

相关文章:

javascript - 将默认日期转换为另一个日期(用户的本地时区)

javascript - 返回复选框值的对象

javascript - 在添加新星级之前重置 JQuery 星级

javascript - 有没有办法让事件总时间始终为24小时

javascript - 是否可以访问 cookie 而不将其发送到请求 header 中?

javascript - jQuery.post 回调未执行

javascript - 将 css 设置为父子大小

javascript - 使用 tinymce 编辑器时,我的数据没有发布到数据库中

javascript - 在 JavaScript 中检查一个数组是否包含另一个数组中带有 null 的元素

javascript - 清空事件下拉列表不起作用