所以我有一個帶有列的網頁。該列有一個固定的標題頂部和一個大的滾動主體部分,下面的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