<style type="text/css"> body{ margin:10px; font-family: Arial; font-size:13px; } #father{ background-color:#a0c8ff; border:1px dashed #000000; width:100%; height:100%; } #block{ background-color: #fff0ac; border:1p dashed #000000; padding:10px; position:absolute; left:20px; top:40px; } </style>
<div id="father"> <div id="block">absolute</div>
height:100%没有将容器撑开。
解决办法:
html,body{/*必须要html和body同时设置height:100%*/ margin:10px; font-family: Arial; font-size:13px; height:100%; }
原文:http://www.cnblogs.com/yee0403/p/5095228.html