2013-01-09 186 views
-1

可能重复:
CSS to make HTML page footer stay at bottom of the page with a minimum height获取页脚留在页面底部

(链接网站:http://www.eastsidespeedway.weebly.com/

请使用上面的链接,你的浏览器开发者工具来查看html/css。

我试图让页面的页脚停留在页面的底部。它现在看起来可能已经停止,但这只是因为它适合页面。例如,如果你转到/404.html,你会发现它是一个无标题的页面,并且页脚几乎在页面的一半处!我使用Weebly添加内容等,但我使用Dreamweaver来构建网站。我在网上尝试了多种东西,但他们似乎使页脚高于实际内容,以至看不到它。我需要它低于内容。

网站的布局是这样的(例子):

<div id="container> 
    <div id="navigation"></div> 
    <div id="content"></div> 
</div> 

<div id="footer-container> 
    <div id="footer"></div> 
</div> 

你可以看到,页脚是在一个单独的容器中。这是因为有一个背景图片需要显示100%的页面宽度,而容器的宽度是960px。

我对html/css有点新,所以对不起,如果你不太明白。

再次,如果您需要任何帮助,请使用浏览器中的开发人员工具。 :P

任何意见,建议,答案表示赞赏。

+0

我必须投票,因为有很多关于如何在网络上实现这一目的的教程和材料。 – Kermit

+0

好吗?我确实相信我说过我经历了一系列教程,但他们都不工作。其中一半是把它们放在页面的底部,另一半是各种各样的东西。我是新来的HTML/CSS .. –

+0

不是?它不是重复的?与我正在使用/做的完全不同的事情。 –

回答

0

只需添加到#footer-container

position:absolute; 
bottom:0px; 

为了把footer在页面的底部。

+0

我试过了,它将页脚放在页面中间。这里是我用来查看是否有任何错误会导致这种情况的代码。 –

+0

'} #页脚容器{ \t字体家庭:宋体,日内瓦,无衬线; \t text-align:center; \t身高:自动; \t margin-right:auto; \t margin-left:auto; \t vertical-align:bottom; \t top:auto; \t颜色:#FFF; \t bottom:0; \t position:absolute; \t background:url(footer_bg.png)no-repeat center bottom; \t宽度:100%; } #footer的{ \t高度:90像素; \t width:960px; \t text-align:center; \t margin-right:auto; \t margin-left:auto; \t font-family:verdana; \t color:#fff; \t} #footer a { \t color:#fff; \t text-decoration:none; } #footer的:悬停{ \t颜色:#FFF; \t text-decoration:underline; }' –

+0

我只放了那两行代码,它工作。 [图片](http://postimage.org/gallery/4nnudx3s/815f7952/) – Vucko

1

EDITED

<div id="wrapper"> 
    <header></header> 
    <div id="main"></div> 
    <footer></footer> 
</div> 

body, html, #wrapper { height: 100%; } /* Create space for elements to be 100% */ 
#wrapper { display: table; } /* Create a table-structure */ 
#wrapper > * { display: table-row; } /* All direct children behave as rows */ 
#wrapper > header, 
#wrapper > footer { min-height: 100px; } /* These must be at least 100px */ 
#main { height: 100%; } /* Let the mid section fill up the remaining space */ 
+0

这也没有工作。它将页脚放在屏幕的底部,但留在那个位置。例如,如果我有一个需要向下滚动的页面(因为在该空间中显示的内容太多),页脚将停留在该位置 –

+0

嗯,我很喜欢使用表格。 lemme调整我的答案 –

+0

完成。这是我使用具有实体元素的流体布局的方式。表结构允许您用流体元素填充剩余空间。在这种情况下,主要部分将页脚向下推至100%wrapperheight allowes –