How to open div on center screen p开发者_开发技巧osition ?
You can define a size for the DIV and position it absolutely (or Fixed), like this:
div{
position:absolute; /* can also be 'fixed' */
top:50%; left:50%;
width:200px; height:100px;
margin:-100px 0 0 -50px;
z-index:99;
}
Or if you don't want to place it absolutly positioned, you can give it a width, and set it to:
div{ margin:0 auto; }
div{
margin-left: auto;
margin-right: auto;
}
This only works if the div has a width of 95% or less
精彩评论