2012-03-26 56 views
0

我用下面的一段代码在浏览器底部对齐一个div股利在浏览器底部

CSS:

/* using the child selector to hide the 
following body css from IE6 and earlier */ 
html>body { 
    background-color: yellow; 
} 

#footer { 
    position:absolute; 
    right:0; 
    bottom:0; 
    background-color:Yellow; 
} 

HTML:

<div id="footer"> 
CCC 
</div> 

这种运作良好,当页适合页面:

works well

但是当页面长度超过然后,如果我滚动页面的股利也越来越顶部滚动显示:

not working well

我已经把页脚DIV顶部顶部用户控制。在页脚div之后还有其他一些控件。这会导致问题吗?

回答

3
#footer { 
    position: fixed; 
    right:0; 
    bottom:0; 
    background-color:Yellow; 
} 

绝对相对于html正文绝对的,固定相对于所述框架

差异与其他值position tag are here

+0

这是一个。 – Darbio 2012-03-26 12:04:40

+0

由于div后面的控件很少,div的显示如图所示:http://i.imgur.com/I9vVv.png。但我希望这是在浏览器底部 – Techonthenet 2012-03-26 12:12:37

+0

拿一个浮动到底部的d​​iv,并将这些控件放在该图层内。我认为职位:固定是解决方案的一部分,但还不够,您应该使用我的或丹佛人的完整解决方案,以使其正常工作。 – 2012-03-26 16:36:49

1

您应该使用固定位置,而不是绝对。 使用该代码:

/* using the child selector to hide the 
following body css from IE6 and earlier */ 
html>body { 
    background-color: yellow; 
} 

#footer { 
    position:fixed; 
    right:0; 
    bottom:0; 
    background-color:Yellow; 
} 
+0

在更新之前给出了相同的解决方案 – 2012-03-26 12:06:38