我试图在用户点击按钮时显示loading.gif /旋转轮.我在母版页中添加了如下所示的div:
<div id="loadingDiv">
<div>
<h7>Please wait...</h7>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
这是css:
#loadingDiv{
position:absolute;
top:0px;
right:0px;
width:100%;
height:100%;
background-color:#666;
background-image:url('ajax-loader.gif');
background-repeat:no-repeat;
background-position:center;
z-index:10000000;
opacity: 0.4;
filter: alpha(opacity=40); /* For IE8 and earlier */
}
Run Code Online (Sandbox Code Playgroud)
当我尝试这个时,loading.gif显示在页面的中心.但由于页面很长,我必须滚动才能看到loading.gif.
如何在屏幕中央显示loading.gif?如果我向下滚动,我应该再次在屏幕中央看到它.
Ank*_*nia 37
这是解决方案.. JS FIDDLE DEMO
HTML
<body>
<div class="content">
Long Content Here
<br/>
Click to view loading image.
</div>
<div id="divLoading">
</div>
Run Code Online (Sandbox Code Playgroud)
CSS
#divLoading
{
display : none;
}
#divLoading.show
{
display : block;
position : fixed;
z-index: 100;
background-image : url('http://loadinggif.com/images/image-selection/3.gif');
background-color:#666;
opacity : 0.4;
background-repeat : no-repeat;
background-position : center;
left : 0;
bottom : 0;
right : 0;
top : 0;
}
#loadinggif.show
{
left : 50%;
top : 50%;
position : absolute;
z-index : 101;
width : 32px;
height : 32px;
margin-left : -16px;
margin-top : -16px;
}
div.content {
width : 1000px;
height : 1000px;
}
Run Code Online (Sandbox Code Playgroud)
jQuery的
$(document).ready(function(){
$("div.content").click(function(){
$("div#divLoading").addClass('show');
});
});
Run Code Online (Sandbox Code Playgroud)
Ehs*_*jad 12
我曾经有过这个html和css,无论我的页面是长还是短,它总是显示在中心:
<div id="divLoading" style="margin: 0px; padding: 0px; position: fixed; right: 0px; top: 0px; width: 100%; height: 100%; background-color: rgb(102, 102, 102); z-index: 30001; opacity: 0.8;">
<p style="position: absolute; color: White; top: 50%; left: 45%;">
Loading, please wait...
<img src="images/ajax-loading.gif">
</p>
</div>
Run Code Online (Sandbox Code Playgroud)