所以我有一个带有列的网页。该列有一个固定的标题顶部和一个大的滚动主体部分,下面的HTML/CSS可以正常工作。用固定宽度标题填充在滚动列的底部
问题:我想添加填充到主体的底部,所以如果你一直向下滚动,你会得到一些空白,而不是让所有东西都卡在底部边缘。在Chrome中完美添加padding-bottom: 50px
至.body
;然而,在Firefox中,似乎使用bottom
属性意味着padding-bottom
被忽略。如果您丢弃bottom
,则显示填充,但滚动条消失。
的test.html
<link type="text/css" rel="stylesheet" media="all" href="/test.css">
<div class="column">
<div class="header">
Fixed header
</div>
<div class="body">
<h1>Body</h1>
Where's the bottom padding?
</div>
</div>
test.css
.column {
position: absolute;
height: 100px;
width: 100%;
background-color: green;
}
.header {
position: absolute;
height: 30px;
background-color: red;
}
.body {
position: absolute;
top: 30px;
bottom: 0;
overflow-y: auto;
background-color: blue;
padding-bottom: 50px; /* Broken in Firefox */
}
的jsfiddle为上述:http://jsfiddle.net/jpatokal/PBwVa/
有没有办法解决?我想到的一个解决方法是使用一串:last-child
选择器来添加填充到.body
中的最后一个元素,但是,eww。
美丽,谢谢! – jpatokal