我正在使用Bootstrap示例,使用CSS创建一个粘性页脚的网站,这一切都很好地工作,当页面被调整大小时,页脚仍然保持在页面底部。在许多页面上,我有需要显示实际全页的内容,除了页脚。因此,页面的内容部分需要设置为100%高度,以便其内容反过来可以调整为全高度。
这里是一个JSFiddle演示问题。
我们如何使绿色容器div成为全高度,因此它在顶部接触页面顶部,在底部接触页脚顶部?
谢谢!
谢谢!
<div id="wrap">
<!-- Begin page content -->
<div class="container">
<div class="page-header">
<h1>Sticky footer</h1>
</div>
<p class="lead">This is the sticky footer template taken from the Bootstrap web site.</p>
<p class="lead">How can we make this green .container div the full height of its parent #wrap div?</p>
</div>
<div id="push"></div>
</div>
<div id="footer">
<div class="container"></div>
</div>
#wrap .container {
background-color: lightgreen;
}
/* Sticky footer styles */
html, body {
height: 100%;
/* The html and body elements cannot have any padding or margin. */
}
/* Wrapper for page content to push down footer */
#wrap {
min-height: 100%;
height: auto !important;
height: 100%;
/* Negative indent footer by it's height */
margin: 0 auto -60px;
}
/* Set the fixed height of the footer here */
#push, #footer {
height: 60px;
}
#footer {
background-color: #f5f5f5;
}