【发布时间】:2016-02-28 20:26:30
【问题描述】:
我正在创建一个 div 作为页脚:
<div class="content">blah blah blah</div>
<div class="content">more content</div>
<div class="content">even more content</div>
<div id="footer">blah blah blah</div>
页脚的 CSS 如下:
#footer{
height: 50px;
display: block;
position: absolute;
right: 0;
left: 0;
bottom: 0;
}
那么我如何在content 和footer 之间留一个50px 空格?我尝试在两者之间添加一个间隔 div 但没有成功。间隔 div 需要超过 content 的高度才能产生效果。我试过margin-top 到#footer,但没有用,但我不希望margin-bottom 用于content,因为内容容器是多个。为content 设置下边距会破坏它们的渲染方式。感谢您的帮助。
附:这不是 Set position absolute and margin 的重复。
【问题讨论】:
-
当绝对定位时这并不理想......你想达到什么目标?
-
好吧,
bottom仅在position: absolute时有效。另外,我想将#footer保留在页面底部。 -
你能提供一个你正在尝试的小草图吗?我们无法仅从您提供的代码中猜出您想要什么......
-
感谢 j08691。我已经纠正了错字。
-
@Milkmannetje 我已经添加了草图。