2014-01-21 164 views
-1

所以即時製作一個非常基本的網站與照片庫,我有這個css爲我的頁腳。基本站點需要的CSS幫助

#footer 
{ 
color: #f0c; 
font-size: 9px; 
font-family: Verdana, Geneva, Arial, sans-serif; 
background-color: #c00; 
text-align: center; 
position: absolute; 
bottom: 0px; 
left: 0px; 
width: 100%; 
height: 18px 

,酒吧不與頁面的其餘部分向下滾動,而不是與頁面這樣滾動起來:http://i.imgur.com/yqM9WDM.png

幫助很大apreciated!

+0

你想要它在哪裏?你有位置:絕對所以它總是在頁面的底部 – Naele

+0

使用位置:固定; –

+0

也許這個鏈接可以幫助你很多:在這裏輸入鏈接的描述] [1] [1]:http://stackoverflow.com/questions/3774882/how-to-make-element-scroll -with-you-on- –

回答

1

我不完全確定你想從你的描述中實現什麼,也不能評論。你是否試圖將紅色欄放在窗口的底部?

在這種情況下,重要的CSS是:

#footer { 
    position: fixed; 
    bottom: 0; 
} 

這將它粘在視窗(滾動可視區域)的底部。其餘的樣式取決於你。

順便說一下,最好使用一個類(.footer)而不是ID(#footer)。

0

使用position: fixedposition: sticky而不是position: absolute來解決頁面上的問題。閱讀this文章以更好地瞭解職位如何運作。

0

如果我理解你正確地,那麼你想要的是使用position:fixedposition:absolute

固定位置會從字面上解決您的要素到位。 這裏有一個小提琴與它的行動 - http://jsfiddle.net/mSE6c/

0

這個工作適合你嗎?

CSS:

* { 
margin:0; 
} 

html, body { 
height: 100%; 
} 

#inhalt { 
min-height: 100%; 
height: auto !important; 
height: 100%; 
margin: 0 auto -30px; 
} 

#footer, #clearfooter { 
height: 30px; 
} 

HTML:

<div id="inahlt">Inhalt <div id="clearfooter"></div></div> 
<div id="footer">Footer</div> 

來源:

http://www.flashjunior.ch/school/footers/fixed_stop.cfm

0

使用position:fixed而不是position:absolute,這將保持在一個位置。

http://jsfiddle.net/PM9Xt/顯示了這一行爲。 top:0保持頂部的標題,而bottom:0保持底部底部。