I need to position div popup to the center of browser screen ( no matter what size the screen is). And I want to keep the position as absolute as I don\'t want to move the p
Its a classical problem, when you scroll the modal popup generated on the screen stays at it place and does not scroll along, so the user might be blocked as he might not see the popup on his viewable screen.
The following link also provides CSS only code for generating a modal box along with its absolute position.
http://settledcuriosity.wordpress.com/2014/10/03/centering-a-popup-box-absolutely-at-the-center-of-screen/
I think you need to make the .holder
position:relative;
and .popup
position:absolute;
It took a while to find the right combination, but this seems to center the overlay or popup content, both horizontally and vertically, without prior knowledge of the content height:
HTML:
<div class="overlayShadow">
<div class="overlayBand">
<div class="overlayBox">
Your content
</div>
</div>
</div>
CSS:
.overlayShadow {
display: table;
position: fixed;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.75);
z-index: 20;
}
.overlayBand {
display: table-cell;
vertical-align: middle;
}
.overlayBox {
display: table;
margin: 0 auto 0 auto;
width: 600px; /* or whatever */
background-color: white; /* or whatever */
}