外链网盘网站,专做奢侈品品牌的网站,教育网站建设解决方案,seo和sem的概念页脚置底(Sticky footer)就是让网页的footer部分始终在浏览器窗口的底部。当网页内容足够长以至超出浏览器可视高度时#xff0c;页脚会随着内容被推到网页底部#xff1b;但如果网页内容不够长#xff0c;置底的页脚就会保持在浏览器窗口底部。方法一#xff1a;将内容部分…页脚置底(Sticky footer)就是让网页的footer部分始终在浏览器窗口的底部。当网页内容足够长以至超出浏览器可视高度时页脚会随着内容被推到网页底部但如果网页内容不够长置底的页脚就会保持在浏览器窗口底部。方法一将内容部分的margin-bottom设为负数footerhtml, body {margin: 0;padding: 0;height: 100%;}.wrapper {min-height: 100%;margin-bottom: -50px; /* 等于footer的高度 */}.footer, .push {height: 50px;}这个方法需要容器里有额外的占位元素(div.push)。div.wrapper的margin-bottom需要和div.footer的-height值一样注意是负height。方法二将页脚的margin-top设为负数给内容外增加父元素并让内容部分的padding-bottom与页脚的height相等。footerhtml, body {margin: 0;padding: 0;height: 100%;}.content {min-height: 100%;}.content-inside {padding: 20px;padding-bottom: 50px;}.footer {height: 50px;margin-top: -50px;}方法三使用calc()设置内容高度footer.content {min-height: calc(100vh - 70px);}.footer {height: 50px;}这里假设div.content和div.footer之间有20px的间距所以70px50px20px方法四使用flexbox弹性盒布局以上三种方法的footer高度都是固定的如果footer的内容太多则可能会破坏布局。footerhtml {height: 100%;}body {min-height: 100%;display: flex;flex-direction: column;}.content {flex: 1;}方法五使用Grid网格布局footerhtml {height: 100%;}body {min-height: 100%;display: grid;grid-template-rows: 1fr auto;}.footer {grid-row-start: 2;grid-row-end: 3;}