【发布时间】:2010-01-25 18:18:24
【问题描述】:
大家好
我正在设计一个布局流畅的网页。我想保持 100% 的宽度和 100% 的高度。 问题是我不知道如何让 div “左”和“右”在其父 div 内保持 100% 的高度,“包装器”。
<div id="container" style="width:100%; height:100%">
<div id="header" style="width:100%; height:100px">
</div>
<div id="wrapper" style="width:100%; height:(100% - 100px)">
<div id="left" style="width:250px; height:(100% - 100px)">
</div>
<div id="right" style="width:(100% - 250px); height:(100% - 100px)">
</div>
</div>
</div>
请帮忙。
来自 doctype.com 的回答
CSS
html, body{
height: 100%;
margin: 0;
padding: 0;
}
HTML
<body>
<div id="container" style="width:100%; height:100%; position: absolute;">
<div id="header" style="width:100%; height:100px;">
header
</div>
<div id="wrapper" style="width:100%; height:auto; position: absolute; top: 100px; bottom: 0;">
<div id="left" style="width:250px; height:100%; float:left;">
left
</div>
<div id="right" style="width: 250px; height:100%; float:right; ">
right
</div>
main content
</div>
</div>
</body>
【问题讨论】:
-
如果您在附属网站 doctype.com 中提出此问题,您可能会有更好的回答机会