根据我的研究,这似乎是一个绝对经典的 CSS 问题,但我不能找到一个明确的答案-所以 StackOverflow 它。
如何设置一个内容 div 来占用100% 的主体高度,减去固定高度的页眉和页脚所占用的高度?
<body>
<header>title etc</header>
<div id="content">body content</div>
<footer>copyright etc</footer>
</body>
//CSS
html, body {
height: 100%;
}
header {
height: 50px;
}
footer {
height: 50px;
}
#content {
height: 100% of the body height, minus header & footer
}
我想使用纯 CSS,并且为了使答案在浏览器之间是防弹的。