2 回答
TA贡献2012条经验 获得超12个赞
我通过将所有内容放在一个页面容器中并在除页脚之外的所有内容中放置一个内容包装器来获得它。
应用程序.jsx
const App = () => (
<div className='App'>
<div className='page-container'>
<div className='content-wrapper'>
<NavigationBar />
</div>
<Footer />
</div>
</div>`);`
应用程序.css
.page-container {
display: flex;
flex-direction: column;
min-height: 100vh;
}
.content-wrapper {
flex: 1;
}
TA贡献1828条经验 获得超6个赞
这个想法是要有固定的页脚高度和主要内容高度,即所有高度减去页脚高度。
你的模板代码应该是这样的:
<div id="root">
<main>
Some main content
</main>
<footer>
Some footer content
</footer>
</div>
款式:
#root {
main {
min-height: calc(100vh - 100px);
}
footer {
height: 100px;
}
}
添加回答
举报
