2012-12-13 69 views
-1

即使在滾動時,如何在瀏覽器屏幕的底部設置div逗留?使用CSS或jQuery的粘滯頁腳

+0

http://www.google.com/search?q=sticky+footer+using+css –

+1

@Pranav我看到你的谷歌搜索,並提出你一個網站搜索:http://stackoverflow.com/search?q=sticky+footer+css 759個問題。愚蠢的愚蠢。 –

+0

[CSS,粘性頁腳]的可能重複(http://stackoverflow.com/questions/10465250/css-sticky-footer),[粘性頁腳CSS](http://stackoverflow.com/questions/5822825/sticky- footer-css)以及與這些問題相關的數十個問題。 –

回答

3

使用position: fixed財產的附加到該div的CSS。

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

假設你有以下的div

<div class="footer">This is at the bottom</div>

你可以把它貼在視口的底部與下面的CSS

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

滾動時,會呆在那裏連。

1

有這個CSS一試:

* { 
    margin: 0; 
} 
html, body { 
    height: 100%; 
} 
.wrapper { 
    min-height: 100%; 
    height: auto !important; 
    height: 100%; 
    margin: 0 auto -142px; /* the bottom margin is the negative value of the footer's height */ 
} 
.footer, .push { 
    height: 142px; /* .push must be the same height as .footer */ 
} 

CSS來源:http://ryanfait.com/sticky-footer/