我有一个页面已经有一个页脚永久“底部对齐”,使用高度为 100% 的容器和以下 css:
#footer {
position: absolute;
left: 0px;
right: 0px;
bottom: 0px;
font-size: 12px;
}
Run Code Online (Sandbox Code Playgroud)
我想要做的是让我的页面表单的按钮(在下面的 html 中由类为“actionButtons”的 div 表示)始终直接位于页脚上方,而不管表单的其他内容如何。我可以保证表单的内容永远不会造成溢出。
<html>
<body>
<div>
<div class="wideContent">
<form>
<div class="actionButtons" style="text-align:right;">
</div>
</form>
</div>
</div>
<div id="footer"></div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我一直在搞乱高度/最小高度,但没有成功。我需要什么 css 才能使上面的 html 始终将“actionButtons”div 放置在窗口底部、页脚上方?先感谢您。
因为我能想到的将按钮强制到底部的唯一方法是<form>,例如......position:relativeposition:fixed
#footer {
position:absolute;
left:0;
right:0;
bottom:0;
font-size:12px;
height:25px;
}
.actionButtons {
position:fixed;
bottom:25px;
left:0;
right:0;
height:10px;
}
Run Code Online (Sandbox Code Playgroud)
...如本演示所示。但需要设置一个与其正确放置#footer相匹配的高度。(出于演示目的,我已经包含了一个)。bottom.actionButtonsheight.actionButtons