加载时,叠加层始终位于模态的背面



我想处理一些东西,我使用覆盖层进行加载,一切都很好,直到我用于模态,当我处理某些东西并调用覆盖层进行加载时,它总是在模态的后面,我怎样才能调用模态前面的覆盖层?

以下 CSS 我用于覆盖。

img#loading {
    position: absolute;
    z-index: 1;
    left: 45%;
    top: 30%;
    width: 150px;    
}
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    background-color: rgba(0,0,0,0.5); /*dim the background*/
}

试试这个:

.HTML:

<div id="myModal" class="modal">
    <!-- Modal content -->
    <div class="modal-content">
        <div class="overlay">
            <span class="close">×</span>
            <p>Some text in the Modal..</p>
        </div>
    </div>
</div>

.CSS:

.modal-content{
   position: relative;
}

最新更新