I'm struggling to center a fixed div inside another fixed div. I have tried many things but could not center it. How can i do this?
.overlay {
background: rgba(0, 0, 0, .60);
position: fixed;
width: 100%;
height: 100%;
opacity: 1;
-webkit-transition: opacity .25s ease;
z-index: 3;
margin: 0 auto;
}
.ques_preview_div {
width: 60em;
height: 30em;
top: 20%;
position: fixed;
background-color: #adadad;
margin: 0 auto;
z-index: 4;
}
<div class="overlay">
<div class="ques_preview_div">
</div>
</div>
I could achieve what i needed by giving the position relative to ques_preview_div . But i need it to have position fixed.