我也有類似的問題,可以找到here。但是我不能讓它工作,或者我完全不瞭解它。填充內容背景直到它到達頁腳
我試圖解決的問題是 - 即使沒有足夠的內容顯示,我也希望我的內容背景能夠達到頁腳。我創建了一個簡單的小提琴,可以找到here。正如你所看到的,沒有足夠的內容可以達到頁腳,內容和頁腳之間有這個「藍色」空間。我想讓這個空間變成灰色。
HTML:
<div class=blue>header here</div>
<p>LOGO here</p>
<div class="blue">navigation bar here</div>
<div class="content">
No content.
</div>
<div class="footer">footer is here</div>
CSS:
.blue {
color: #ffffff;
background-color: #294a70;
display: block;
float: none;
width: 400px;
margin: 0 auto;
text-align: center;
}
p {
text-align: center;
color: #ffffff;
}
.content {
background-color: #e6e6e6;
display: block;
float: none;
margin: 0 auto;
overflow:hidden;
width:400px;
margin-bottom:30px;
}
.footer {
color: #ffffff;
background-color: #294a70;
display: block;
float: none;
width: 400px;
margin: 0 auto;
text-align: center;
position: absolute;
bottom: 0;
left: 0;
right: 0;
height:30px;
}
body {
margin:0;
padding:0;
font-family: 'Open Sans', sans-serif;
line-height: 1.5;
font-size: 14px;
overflow-x:hidden;
background-image:url('http://www.planwallpaper.com/static/images/Alien_Ink_2560X1600_Abstract_Background_1.jpg');
min-height: 100%;
}
html {
position:relative;
min-height: 100%;
}
所有幫助將不勝感激!
我曾經在讀過關於vh單元的一些內容,但並不理解它們,你只是簡單地將它和我的例子設法在我的網站上實現它。所以謝謝你解決這個問題給我。 – RebelInc