position:absolute;的DIV 如何居中

来源:互联网 发布:好看的悬疑网络剧 编辑:程序博客网 时间:2024/05/16 01:17

外层DIV{position:realtive}
内层DIV{positon:absolute;top:50%;left:50%;margin-top:-100px;margin-left:-150px;width:300px;height:200px;}

<div class="father">    <div class="son">    </div></div>
.father{    position:realtive;    width:100%;    height:100%;}.son{    position: absolute;    left: 50%;    top: 50%;    z-index: 1;    width: 1200px;    margin-left: -600px;    height:600px;    margin-top:-300px;}
0 0