【发布时间】:2020-04-01 10:46:32
【问题描述】:
我在codepen 上发现了一个 sn-p,它添加了一个加载器,直到内容完全加载。
// makes sure the whole site is loaded
jQuery(window).load(function() {
// will first fade out the loading animation
jQuery("#status").fadeOut();
// will fade out the whole DIV that covers the website.
jQuery("#preloader").delay(1000).fadeOut("slow");
})
#preloader {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #fff;
z-index: 99;
height: 100%;
}
#status {
width: 200px;
height: 200px;
position: absolute;
left: 50%;
top: 50%;
background-image: url(http://opengraphicdesign.com/wp-content/uploads/2009/01/loader64.gif);
background-repeat: no-repeat;
background-position: center;
margin: -100px 0 0 -100px;
}
.flex {
display: flex;
width: 100%;
}
.flex > div {
height: 200px;
width: 50%;
position: relative;
}
.left {
background: red;
}
.right {
background: black;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<div id="preloader">
<div id="status"></div>
</div>
<img src="##">
<div class="flex">
<div class="left"></div>
<div class="right"></div>
</div>
我如何为每个 div 框添加一个加载器,而不是向整个页面添加一个加载器?
我看到另一个参考 here 我正在努力实施和 here is how far I got with my codepen。
【问题讨论】:
-
您在尝试实施方面做得如何?
-
我将不得不回滚我的 sn-p,因为当前是我最后一次尝试。实际上会创建一个新的。
-
@IslamElshobokshy 在我编辑的问题中有另一个 sn-p。我以为是图像引用,但加载器仍然没有显示
标签: javascript jquery html css