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;
}
}
添加回答
舉報