When the z-index of the parent element is lower, the children elements will have a higher z-index than their parent.
For example, setting the z-index of 'modal-wrapper' to 100 won't work because its parent element, 'paper-header', has a z-index of 2.
Therefore, the children's z-index will be 2.
The solution is simple:
Just make the sibling element of paper-header and it will work fine.
.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>
---- thank you ----