如何对齐HTML底部中心的页脚 [英] How to align the footer at the bottom center in HTML
问题描述
我想将页脚对齐到页面底部的中心,但下面的代码不起作用。你能告诉我应该做什么改变吗?
I want to align the footer at the bottom center of the page but the code below doesnt work. Could you please tell me what changes should i make ?
<style type="text/css">
#footer {
bottom : 2;
height : 40px;
margin-top : 40px;
text-align: center;
vertical-align: middle;
}
</style>
<div id="footer">Terms and Conditions </div>
推荐答案
起初 底部
值应该在 px
或%
中。请检查此 CSS:BOTTOM ,它只有在组合它与任何位置
属性,请检查此 CSS:POSITION
At first bottom
value should be in px
or %
. Check this CSS : BOTTOM , and it will work only if you combined it with any position
property, Check this CSS:POSITION
如果您希望将页脚始终放在页面底部,则可以使用 position:fixed
和 bottom:< value>
。
And if you want place the footer always at the bottom of your page you can use a combination of position:fixed
and bottom:<value>
.
最后设置div width:100%
,使其占据整个浏览器窗口的宽度这,
And finally set the div width:100%
to make it occupy the whole width of the browser window
like this,
#footer {
bottom : 2px;
height : 40px;
margin-top : 40px;
text-align: center;
vertical-align: middle;
position:fixed;
width:100%;
}
这篇关于如何对齐HTML底部中心的页脚的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!