我想在页面底部居中放置一个按钮:
<footer>
<div class="centerContent">
<input name="submit" type="submit" />
</div>
</footer>
CSS:
.centerContent {
text-align: center;
}
footer {
clear: both;
height: 100px;
position: absolute;
bottom: 0;
}
如果删除CSS的“页脚”部分,则该按钮当然不在页面底部,但至少在页面水平中心。如果我将“页脚”部分留在CSS中,则该按钮位于页面底部,但是.....它不再位于水平居中位置!!!有人知道为什么吗?非常感谢。
最佳答案
对于水平对齐,应将页脚拉伸到全宽。将width:100%
添加到footer
样式。
.centerContent {
text-align: center;
}
footer {
clear: both;
height: 100px;
position: absolute;
bottom: 0;
width: 100%;
}