2016-02-25 118 views
1

因此,這裏是我的代碼:DIV的高度CSS問題

#logo { 
position:fixed; 
color: white; 
width: 100%; 
padding: 5px; 
left:0px; 
top:0px; 
height:50px; 
width:100%; 
background:#ffffff; 
z-index: 1; 
} 

#page-container { 
margin: auto; 
width: 960px; 
height: 100%!important; 
background: #ffffff; 
border-style: solid; 
border-color: red; 

} 

html, body { 

padding: 0; 
} 

body { 
font-family: Arial, Helvetica, Verdana, Sans-serif; 
font-size: 12px; 
color: #000000; 
background-color: #eef3f7; 
} 

#footer { 
position:fixed!important; 
position:absolute; 
color: white; 
clear: both; 
width: 100%; 
padding: 0; 
left:0px; 
bottom:0px; 
height:30px; 
background:#272695; 
text-align:center; 
} 

我希望能夠讓頁腳了幾圈它一路走過來設置頁面容器高度。我得到的問題是這樣的:

ScreenCap

我要的是有我的網頁內容規則來覆蓋整個頂部和底部沒有重疊。我在尋找沿此線的東西:

Mock Up

老實說,我已經試過各種我只是不知道是什麼問題。

+1

你可以發佈你的HTML代碼嗎? – Eria

+0

正如@Eria所說的,需要將您的html發佈到某處供我們查看。 –

+1

很難理解你的目標是什麼,_「我希望能夠設置頁面容器的高度,以便頁腳完全覆蓋它。」_有點不清楚。你在問一個[sticky footer](http://ryanfait.com/sticky-footer/)嗎? – hungerstar

回答

2

添加到您的CSS。到它的父和高度默認爲auto

body, html { 
    height: 100%; 
} 

的CSS height屬性是相對的。所以爲了讓你的#頁面容器成爲100%,你必須設置父高度。

+0

哦,我明白了,謝謝! –