本站首页    管理页面    写新日志    退出


«November 2025»
1
2345678
9101112131415
16171819202122
23242526272829
30


公告
暂无公告...

我的分类(专题)

日志更新

最新评论

留言板

链接


Blog信息
blog名称:
日志总数:16
评论数量:42
留言数量:1
访问次数:84919
建立时间:2007年5月10日




自适应高度布局
读书笔记

kcruci 发表于 2007/7/12 15:36:38

自适应高度布局星期五 03.17.2006 - Posted in Web客户端技术, No Tags 500)this.width=500'>要实现的是head foot固定,中间区域随内容高度自适应,拖动滚动条时foot永远居底。 SolarDreamStudios的方案给了我一个很好的思路,但关键部分是原创的,一直以为会比SolarDreamStudios的方案好,结果仔细看他们的代码,才发现其实原理都差不多,不过他们似乎在兼容性上下了更多工夫,具体未测试。 A. 宽度100%自适应 结构代码 <body> <div id="head">head</div><div id="head_height"></div> <div id="middle"></div> <div id="foot_height"></div><div id="foot">foot</div> </body>[/code]表现代码 #head { width:100%; text-align:center; background:#FF9400; height:100px; position:absolute; top:0;}$nbsp$$nbsp$#head_height { height:100px;}#middle { margin:20px;}#foot { width:100%; text-align:center; background:#f00; height:100px; position:absolute; bottom:0;}* html #foot { bottom:-1px;}$nbsp$$nbsp$#foot_height { height:100px;} Demo http://www.rexsong.com/blog/attachments/200603/17_095405_height100_a.htm B. 宽度固定居中 结构代码 <body> <div id="head">$nbsp$$nbsp$<div id="head_content">head</div></div><div id="head_height"></div> <div id="middle"></div> <div id="foot_height"></div><div id="foot">$nbsp$$nbsp$<div id="foot_content">foot</div></div> </body> 表现代码 #head { width:100%; text-align:center; position:absolute; top:0; left:0;}$nbsp$$nbsp$#head_content { line-height:100px; width:700px; margin:0 auto; background:#FF9400; height:100px;}$nbsp$$nbsp$#head_height { height:100px;}#middle { margin:20px;}#foot { width:100%; text-align:center; position:absolute; bottom:0;}* html #foot { bottom:-1px;}$nbsp$$nbsp$#foot_content { line-height:100px; width:700px; margin:0 auto; background:#f00; height:100px;}$nbsp$$nbsp$#foot_height { height:100px;} Demo http://www.rexsong.com/blog/attachments/200603/17_095422_height100_b.htm 测试环境IE6.0和FF1.5,IE环境下因为BUG有时会自动出现滚动条(SolarDreamStudios的方案一样),FF下为完美效果。 ForumDIV+CSS如何实现中间区域自适应高度? http://www.blueidea.com/bbs/NewsDetail.asp?lp=2&id=2494868三行两列布局能否最小高度为100%? http://dw8.cn/forum/NewsDetail.asp?id=1295 ReferrenceA more robust method of positioning a footer http://www.themaninblue.com/writing/perspective/2005/08/29/footerStick http://solardreamstudios.com/learn/css/footerstick/


阅读全文(1521) | 回复(0) | 编辑 | 精华
 



发表评论:
昵称:
密码:
主页:
标题:
验证码:  (不区分大小写,请仔细填写,输错需重写评论内容!)



站点首页 | 联系我们 | 博客注册 | 博客登陆

Sponsored By W3CHINA
W3CHINA Blog 0.8 Processed in 0.418 second(s), page refreshed 144802591 times.
《全国人大常委会关于维护互联网安全的决定》  《计算机信息网络国际联网安全保护管理办法》
苏ICP备05006046号