Html CSS 将 Div 推送到页面底部

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2140763/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 01:59:16  来源:igfitidea点击:

CSS Push Div to bottom of page

htmlcss

提问by FrozenMicrowavedPIzza

I want the footer to always be at the bottom of the page even if the content doesn't push it all the way down. How can I make it just stay at the bottom of the page?

我希望页脚始终位于页面底部,即使内容没有将其一直向下推。我怎样才能让它只停留在页面底部?

回答by Bryan A

 #footer { position: fixed; bottom: 0; }

回答by Michael Krauklis

If you always want it to be at the bottom of the visible page even when the content pushes down further than the viewable area try absolutely positioning the div and adding a margin to the bottom of your page.

如果您始终希望它位于可见页面的底部,即使内容向下推得比可见区域更远,请尝试绝对定位 div 并在页面底部添加边距。