找回密码
 注册
搜索
热搜: 回贴

Html:网页最窄770px最宽1024px经典布局

2009-12-16 23:31| 发布者: admin| 查看: 48| 评论: 0|原作者: 云忆

最典型实用的上中下,并且中间分三列的布局,这个例子有2个特点:
1. 中间三列效果,可以任意实现单列背景色。
2. 整体最窄770px,最宽1024px,也就是说窗口小于770xp就出底部滚动条,如果大于1024px自动屏幕居中。
IE6.0和FF1.5测试通过
分析:
最外层的wrapper把所有内容都嵌套在里边,整体相对定位。max min已经很好的控制了最窄最宽值,但对IE没有作用。如果没有其他布局的穿插,这一层其实写在body内就可以,少一层嵌套。
#wrapper width:auto; border:1px solid #000; min-width:770px; max-width:1024px; text-align:left; margin-left:auto; margin-right:auto; position:relative;
wrapper 下级的 outer header footer
其中header绝对定位,footer 相对定位;outer分别对左右有130px的外边距,这是兼容非IE的关键。
#outer margin-left:130px; margin-right:130px; background:silver; border-left:1px solid #000; border-right:1px solid #000; color: #000;
#header position:absolute; top:0; left:0; width:100%; height:70px; line-height:70px; border-bottom:1px solid #000; overflow:hidden; background:#0ff; text-align:center; font-size:xx-large
#footer width:100%; clear:both; line-height:50px; border-top:1px solid #000; background:#ffc; color:#000; text-align:center; position:relative;
outer 下级的 clearheader outerwrap right clearer
clearheader 用做填补header的空白,clearer 是一个常用的填充hack用法。
outerwrap 宽为什么是99%,而不是100%?因为他的上层outer有边框,100%宽再加2个边框象素就会撑大,FF有明显效果。
right 的处理很经典,IE下解析为定位,FF下则为浮动。负边距的处理也刚好使用上outer留出的空白。
#clearheader height:72px;
.outerwrap float:left; width:99%;
#right
position:relative;
width:130px; float:right; left:1px;
margin-right:-129px;

* html #right margin-right:-130px; margin-left:-3px
.clearer height:1px; overflow:hidden; margin-top:-1px; clear:both;
outerwrap 内的 centrecontent left clearer 就很简单了,思路类似上边说明。









Min width of 770px and max width of 1024px


centre content goes here centre content goes here : centre content
goes here centre content goes here : centre content goes here centre
content goes here : centre content goes here centre content goes here
: centre content goes here centre content goes here : centre content
goes here centre content goes here : centre content goes here centre
content goes here : centre content goes here centre content goes here
: centre content goes here centre content goes here : centre content
goes here centre content goes here : centre content goes here centre
content goes here : centre content goes here centre content goes here
: centre content goes here centre content goes here : centre content
goes here centre content goes here : centre content goes here centre
content goes here : centre content goes here centre content goes here
: centre content goes here centre content goes here : centre content
goes here centre content goes here : centre content goes here centre
content goes here : centre content goes here content goes here :





Left content goes here : Left content goes here : Left content goes
here : Left content goes here : Left content goes here : Left content
goes goes here : Left content goes here :


















最新评论

QQ|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )

GMT+8, 2024-9-30 07:28 , Processed in 0.107128 second(s), 12 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

返回顶部