您可以使用绝对定位。
HTML
<div id="content"> <div id="header"> Header </div> This is where the content starts.</div>
CSS
BODY{ margin: 0; padding: 0;}#content{ border: 3px solid #971111; position: absolute; top: 0; right: 0; bottom: 0; left: 0; background-color: #DDD; padding-top: 85px;}#header{ border: 2px solid #279895; background-color: #FFF; height: 75px; position: absolute; top: 0; left: 0; right: 0;}通过
#content绝对定位并指定top,right,bottom和left属性,您将获得一个div占用整个视口。
然后,设置
padding-top上
#content为> =的高度
#header。
最后,将其放置
#header在内部
#content并进行绝对定位(指定顶部,左侧,右侧和高度)。



