【发布时间】:2012-06-25 02:05:54
【问题描述】:
我有 div (#child),它不会扩展到它的父级 (#parent) 的完整高度。我已经为html 和body 设置了高度。如果我将父级的高度设置为 100%,它会起作用,但我希望父级有一个最小高度,而子级扩展到父级的全高。
HTML:
<html>
<body>
<div id="parent">
<div id="child">
<p>This area should be have the same height as it's parent.</p>
</div>
</div>
</body>
</html>
CSS:
html, body, header, h1, p { margin: 0; padding: 0; }
html { background-color: #DDD; height: 100%; }
body { background-color: #DAA; height: 100%; }
#parent {
min-height: 70%;
height: auto !important;
height: 70%;
background-color: #AAD;
}
#child {
height: 100%; /* why isn't this working ? */
width: 80%;
margin: auto;
background-color: #ADA;
}
JSFiddle:http://jsfiddle.net/nxVNX/11/
【问题讨论】: