2

在过去的几周里,我一直在学习 html 和 css。现在我必须为学校制作一个作品集网站,该网站将于下周三到期。可悲的是,我无法让它以我想要的方式工作,并希望在这个网站上找到一些帮助。

我有一个由全宽 div 和全宽页脚组成的网站的想法。计划是让页脚始终贴在 div 的底部(除非屏幕太小,因此页脚不会与内容重叠),并且 div 会根据内容的体积调整大小。它似乎可以在我的小屏幕笔记本电脑上运行,但是当我在屏幕较大的计算机上打开网站时,它无法正确定位页脚。

该网站可在http://home.deds.nl/~gwleuverink/concept/index.html查看。

我希望有人可以帮助我!

4

1 回答 1

1

看这个例子

HTML

<div id="container">
   <div id="header"></div>
   <div id="body"></div>
   <div id="footer"></div>
</div>

CSS

html,
body {
   margin:0;
   padding:0;
   height:100%;
}
#container {
   min-height:100%;
   position:relative;
}
#header {
   background:#ff0;
   padding:10px;
}
#body {
   padding:10px;
   padding-bottom:60px;   /* Height of the footer */
}
#footer {
   position:absolute;
   bottom:0;
   width:100%;
   height:60px;   /* Height of the footer */
   background:#6cf;
}

有关更多信息,请查看此链接http://matthewjamestaylor.com/blog/keeping-footers-at-the-bottom-of-the-page

于 2012-11-01T07:17:28.417 回答