css div随浏览器变动仍居中显示

css源码:

.class1{

position:absolute;

width: 500px;

height: 400px;

top:50%;left:50%;/*显示开始位置是屏幕的中心点*/

margin-top:-200px; /*通过将上边距,向上调整负值,让DIV纵向居中。负值的绝对值应当是height的1/2*/

margin-left:-250px;/*通过将左边距,向左调整负值,让DIV横向居中。负值的绝对值应当是width的1/2*/

margin-right:0px;

margin-bottom:0px;

}

扫描二维码关注公众号,回复: 8666200 查看本文章
发布了98 篇原创文章 · 获赞 19 · 访问量 10万+

猜你喜欢

转载自blog.csdn.net/water_Popcorn/article/details/97623703