1.footer位置的自动适配(主内容不足一屏时显示在最底部,超出一屏时跟随主内容显示)
html
<div class="page"></div>
<div class="footer"></div>
css
.page{min-height: 100vh;padding-bottom: 50px;}
.footer{height:50px;background: #ccc;margin-top: -50px;}
主要注意的是:主内容的min-height,footer的height和margin-top
这篇博客探讨了如何使用CSS确保footer在内容不足一屏时位于页面底部,而当内容超过一屏时,footer能跟随主要内容显示。关键在于设置主内容区域的min-height,footer的高度以及负margin,以此实现灵活的页面布局。
1886

被折叠的 条评论
为什么被折叠?



