2012-12-13 70 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/