+ -
当前位置:首页 → 问答吧 → 有关层贴底部的问题

有关层贴底部的问题

时间:2010-10-11

来源:互联网

002.gif (26.92 KB)
2010-10-11 16:24


基本的结构就是这样
<!-- header  -->
<div class="header">顶部内容</div>
<!-- content  -->
<div class="content">
<div class="left-nav">菜单</div>
<div class="right-main">内容</div>
</div>
<!-- footer -->
<div class="footer"></div>

底部的样式:
.footer{width:100%;color:#fff;position:absolute;bottom:0;left:0;height:21px;line-height:21px;text-align:right;background:url(../images/bottom-bg.gif);}
底部的层:
<div class="footer">ADMIN,你好!你当前IP:21.258.654.12   系统时间:2007-10-15  23:25:10</div>

现在的问题是,当中间的内容不超过一屏的时候,显示是正常的。
01.gif (5.54 KB)
2010-10-11 14:49


但是当中间的内容超过一屏的时候就不行了。

02.gif (11.96 KB)
2010-10-11 14:49


现在想要的是
当content 的内容超过一屏的时候,底部footer跟着走,
当content小于一屏的时候,底部footer显示在浏览器的底部,也就是底部以下不能有空白的地方。

[ 本帖最后由 rayson19840610 于 2010-10-11 16:24 编辑 ]

作者: rayson19840610   发布时间: 2010-10-11

不好意思啊。看错啦。。。还是贴出完整的代码吧。。。

[ 本帖最后由 xiaoxiao7 于 2010-10-11 15:01 编辑 ]

作者: xiaoxiao7   发布时间: 2010-10-11

完整的代码太多了。我就简化一下基本的结构。
<!-- header  -->
<div class="header">顶部内容</div>
<!-- content  -->
<div class="content">
<div class="left-nav">菜单</div>
<div class="right-main">内容</div>
</div>
<!-- footer -->
<div class="footer">ADMIN,你好!你当前IP:21.258.654.12   系统时间:2007-10-15  23:25:10</div>

现在是当right-main的内容超过一屏的时候,底部的footer层就是图二显示的那样了。

作者: rayson19840610   发布时间: 2010-10-11

样式呢?还是不知道你问题所在。还有就是为什么那个要用到层。直接样式不就可以吗?把position:absolute;bottom:0;left:0;去掉不可以吗?

作者: xiaoxiao7   发布时间: 2010-10-11

不行啊。如果内容小于一屏的时候,底部也会跟着上去的。这样的话,下边就空了。

作者: rayson19840610   发布时间: 2010-10-11

现在的意思应该就是,当内容大于一屏的时候,跟着内容走,当小于一屏的时候也只能显示在浏览器的底部。

作者: rayson19840610   发布时间: 2010-10-11


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <style type="text/css"> *{margin:0;padding:0;} html,body{height:100%;} body{position:relative;background:#ccc;} .main{padding-bottom:10px;} .footer{width:300px;height:100px;background:black;position:absolute;bottom:0px;left:0;} </style> </head> <body> <div class="main">这里加内容,这里用了padding-bottom把footer的高度留出来<br /> </div> <div class="footer"></div> </body> </html>
 提示:您可以先修改部分代码再运行
你说的可否是这样的?

[ 本帖最后由 xiaoxiao7 于 2010-10-11 17:34 编辑 ]

作者: xiaoxiao7   发布时间: 2010-10-11