使用CSS的calc函数,在content内容中设置min-height(我用的是heigh,因为只是想实现当前浏览窗口将footer撑开到底部,不需要窗口滚动)。
下面是个例子
HTML部分
<body>
<div id="content">内容区域</div>
<div id="footer">置底区域</div>
</body>
CSS部分
#content {
min-height: calc(100vh - 100px); //100vh比100%好的地方在于即使没有内容也可以把区域撑开
}
#footer {
height: 100px;
}