文章
https://philipwalton.github.io/solved-by-flexbox/demos/sticky-footer/
https://www.w3cplus.com/css3/css-secrets/sticky-footers.html
场景:如果页面内容不够长的时候,页脚块粘贴在视窗底部;如果内容足够长时,页脚会被内容向下推送。
最佳实现方案
<body class="Site"><header>…</header><main class="Site-content">…</main><footer>…</footer></body>.Site {display: flex;min-height: 100vh;flex-direction: column;}.Site-content {flex: 1;}
参考文档
<style>* {margin: 0;padding: 0;}html,body {height: 100%;}.wrapper {height: 100%;display: flex;flex-direction: column;}.content {flex: 1;border: 1px solid black;}.footer {height: 50px;}</style><div class="wrapper"><div class="content">这是内容</div><div class="footer">这是底部</div></div>
