开发者

How to open div on center screen position?

开发者 https://www.devze.com 2022-12-30 16:46 出处:网络
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:

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

0

精彩评论

暂无评论...
验证码 换一张
取 消