【发布时间】:2022-01-07 05:04:33
【问题描述】:
使用HTML/CSS,即使有no enough content,我也需要将footer放在页面的bottom上。
如果有很多内容导致滚动,很容易实现这一点。当没有足够的内容时出现问题,因为在这种情况下,页脚会上升。
这里有一张图片可以更清楚地说明这一点:
我有以下起始代码:
CSS
body {
margin: 0;
}
#header, #content, #footer {
padding: 10px;
}
#header {
height: 100px;
background-color: #abcdef;
}
#content {
bottom: 100px;
left: 0;
right: 0;
background-color: #F63;
overflow: auto;
}
#footer {
position: fixed;
bottom: 0;
left: 0;
right: 0;
height: 100px;
background-color: #abcdef;
}
HTML
<div id="header">
There is the Header
</div>
<div id="content">
hello world<br/>
hello world<br/>
hello world<br/>
hello world<br/>
hello world<br/>
hello world<br/>
hello world<br/>
hello world<br/>
hello world<br/>
hello world<br/>
hello world<br/>
hello world<br/>
hello world<br/>
hello world<br/>
hello world<br/>
</div>
<div id="footer">
There is the Footer
</div>
Jsfiddle 预览:https://jsfiddle.net/bk5ow9us/ (尝试调整窗口的高度)
知道如何实现这一目标吗?
重要
我还需要一个适用于 IE(版本 >= 11)的有效解决方案,而不仅仅是 FF 和 Chrome。
【问题讨论】:
-
仅供参考,网站上已经有大约 3,000 个问题(字面意思)。我敢打赌,您可以通过一些搜索找到答案。
-
Ofc 是重复的,这个问题几乎每天都会被问到。我们应该将它们指向 SO 文档,这就是它们的全部意义
-
@StefanBob 我正在等待他们将结束问题作为指向 SO Docs 的指针...
-
那将是理想的