打开页面时遇到问题,我需要在打开页面之前打开加载图片,我该怎么办
<style>
#dvLoading
{
background:#000 url(images/ajax-loading.gif) no-repeat center center;
height: 100px;
width: 100px;
position: fixed;
z-index: 1000;
left: 50%;
top: 50%;
margin: -25px 0 0 -25px;
}
</style>
$(window).load(function(){
$('#dvLoading').fadeOut(2000);
});
答案 0 :(得分:0)
window.load
将等待加载整个内容,然后启动它。你最好使用'ready',即:
<style>
#dvLoading{
background:#000 url(images/ajax-loading.gif) no-repeat center center;
height: 100px;
width: 100px;
position: fixed;
z-index: 1000;
left: 50%;
top: 50%;
display: none;
margin: -25px 0 0 -25px;
}
</style>
$(function(){
$('#dvLoading').css('display', 'block');
});
$(window).load(function(){
$('#dvLoading').fadeOut(2000);
});
在结束<div id="dvLoading"></div>
</body>
答案 1 :(得分:0)