gpt4 book ai didi

css - 修复了带有 z-index 问题的模态

转载 作者:太空宇宙 更新时间:2023-11-04 07:09:02 25 4
gpt4 key购买 nike

我有一个带有 z-index: 100 的固定模式,但它不在页面上的所有元素之上。它位于 position: relative; 的元素下方z-index: 2; 我不知道为什么?!这是 fiddle .任何帮助,将不胜感激。谢谢!

最佳答案

您需要从 paper-header div 中取出 modal-wrapper div。这是完整的代码。

.paper-header {
align-items: flex-start;
display: flex;
justify-content: space-between;
position: relative;
z-index: 2;
background: #ffffff;
min-height: 8rem;
}

.paper-body {
position:relative;
z-index: 1;
}

.modal-wrapper {
display: flex;
align-items: center;
justify-content: center;
position: fixed;
z-index: 100;
overflow-x: hidden;
overflow-y: auto;
top: 0;
right: 0;
bottom: 0;
left: 0;
}

.modal {
width: 32.5rem;
background-color: #FFFFFF;
border-radius: 4px;
box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.05);
position: relative;
z-index: 101;
padding: 1.25rem;
}

.modal-overlay {
position: absolute;
z-index: 100;
top: 0;
right: 0;
bottom: 0;
left: 0;
padding: 1.25rem;
background-color: rgba(34, 34, 34, 0.5)
}
<div class="wrapper">
<div class="paper-header">
<h1>
Segment 1
</h1>

</div>
<div class="modal-wrapper">
<div class="modal">
modal content
</div>
<div class="modal-overlay"></div>
</div>
<div class="paper-body">
Segment body
</div>

<div class="paper-header">
<h2>
Segment 2
</h2>
</div>
</div>

关于css - 修复了带有 z-index 问题的模态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51337366/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com