<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>子盒子绝对居中</title>
</head>
<style>
#big { margin: 10% auto; position: relative; width: 678px; height: 456px; background: red; }
.small { width: 456px; height: 234px; position: absolute;top:50%;left:50%; margin-left: -228px; /*设置负值,为要定为子盒子的一半宽度*/
margin-top: -117px; /*设置负值,为要定位子盒子的一半高度*/ background: green; } </style>
<div id="big">
<div class="small">
</div>
</div>
</html>
原文地址:http://www.cnblogs.com/jwskbcodeword/p/3778878.html