In some pages, we always encounter some of the window is not centered, but also according to the size of the browser to adjust the pop-up window popup position,
I've had this problem before, and now I'm presenting to you what I know.
CSS Styles
. windowbox{
width:500px;
mid-tanbox{
position:fixed; top:50%; left:50%; Margin-left: -250px; Background: #fff; border:1px solid red; Display:none
}
HTML code
<div class= ' Windowbox ' >
<div class = "Mid-tanbox" ></div>
<div class= "Jclick" > Pinball window </div>
</div>
jquery Code Automatic:
$ (". Jclick"). Click (function (i) {
var height = $ (". Mid-tanbox"). Height ();
var eheight = HEIGHT/2;
$ (". Mid-tanbox"). EQ (i). CSS ("Margin-top", "-eheight");
The above is small series for everyone to bring the JS to achieve a simple example of the center of the bullet window all the content, I hope that we support cloud Habitat Community ~