简体   繁体   English

通过div标签创建透明的加载叠加

[英]creating transparent loading overlay by div tag

I want to create a css class for loading operations. 我想为加载操作创建一个CSS类。 I have div panels that contains ajax request operations. 我有包含ajax请求操作的div面板。 I will overlay loading blur on panel. 我将在面板上叠加加载模糊。 but not working. 但不起作用。 This is my working code 这是我的工作代码

Text and buttons not appearing under the loading incon. 文本和按钮未出现在加载图标下。 my transparent is 0.4 我的透明度是0.4

.main{
    height:     250px;
    width:      300px;
    border: solid 1px red;
    overflow: hidden;
    float:left;
    margin-right:10px;
}
.medium{
    height:     250px;
    width:      100px;
    border: solid 1px blue;
    overflow: hidden;
}
.loading {  
    position:relative;
    z-index:    1000;
    top:        0;
    left:       0;
    height:     100%;
    width:      100%;
    background: rgba( 205, 205, 205, 0.4 ) 
                url('http://www.easyshopindia.com/images/loading.gif') 
                50% 50% 
                no-repeat;
}
body .loading{
    display:block;
    overflow:hidden;
}

<div class="main">
    <div class="loading">
    </div>
    <button>show images</button>
    <p>This is my paragraph.</p>
</div>

<div class="medium">
    <div class="loading">
    </div>
    <button>show info</button>
    <p>hello this is small box</p>
</div>

i think you want to set loading as overlay, for that you have to give the parent element as position: relative and give child loading element position: absolute to fill the parent element. 我认为您想将加载设置为叠加,为此您必须将父元素设置为position: relative并给子加载元素position: absolute来填充父元素。

.main{
height:     250px;
width:      300px;
border: solid 1px red;
overflow: hidden;
float:left;
margin-right:10px;
position: relative;
}
.medium{
    height:     250px;
    width:      100px;
    border: solid 1px blue;
    overflow: hidden;
    position: relative;
}
.loading {  
    position: absolute;
    z-index:    1000;
    top:        0;
    left:       0;
    height:     100%;
    width:      100%;
    background: rgba( 205, 205, 205, 0.4 ) 
                url('http://www.easyshopindia.com/images/loading.gif') 
                50% 50% 
                no-repeat;
}

See this updated jsfiddle :- http://jsfiddle.net/pvvo7kre/7/ 看到这个更新的jsfiddle:-http: //jsfiddle.net/pvvo7kre/7/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM