问题:在完成“就绪”状态后,需要执行很多JavaScript计算来计算width
的div
。我想在document.ready
上的document.load
和div
之间设置这样的加载器时间,以便它等待最终的width
,然后正确显示,这意味着它的宽度悬挂了一段时间,这就是它的加载时间。
如果您无法理解我的问题,请对此问题发表评论。
最佳答案
jQuery(window).load(function(){
// THIS IS ORIGINAL CODE
//jQuery('.loader_main_overlay').css('display','none');
// Alternate way to show loader in this example not exact way
jQuery('.loader_main_overlay').fadeOut(2000);
});
.loader_main{
height:100%;
width:100%;
position:relative;
}
.loader_main_overlay{
position:absolute;
width:inherit;
height:inherit;
background-image:url('http://bildbearbeitung.onl/images/ui/load1.gif');
background-color: #ccc;
opacity: 0.8;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<body>
<div class="loader_main">
<div class="loader_main_overlay">
</div>
<img src="https://static.pexels.com/photos/112576/pexels-photo-112576.jpeg" />
</div>
</body>