我有 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/