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

网页

最典型实用的上中下,并且中间分三列的布局,这个例子有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 就很简单了,思路类似上边说明。

<!--[if gte IE 5]> 指定IE5.0及版本以上浏览器有效

使用expression方法实现对IE5.0及以上版本的宽度条件控制。

body width:expression( documentElement.clientWidth < 770 ? (documentElement.clientWidth == 0 ? (body.clientWidth < 770 ? "770" : "auto") : "770px") : "auto" );
#wrapper width:expression( documentElement.clientWidth > 1024 ? (documentElement.clientWidth == 0 ? (body.clientWidth >1024 ? "1024" : "auto") : "1024px") : "auto" );

开始只想搞清楚老外是如何实现居中min max的,没想到最后是expression,太失望了,其实这里使用脚本控制更好。另外,老外原文的 Min width of 800px 是错的,CSS定义就是770px,后来截屏确认也是770px。

总的来说这是一个很复杂的布局例子,融合了很多经典用法和定义,同时很传统和实用。类似的复杂布局,四层嵌套实现对于传统布局来说还是比较有优势的。

Referrence:
3 col layout with equalising columns and footer

 http://www.pmob.co.uk/temp/min-max-3col.htm

  附:布局代码

<!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>
<title>最窄770px最宽1024px的经典布局</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<style type="text/css">

* margin:0; padding:0;
body padding:10px 0 0 0; color:#000; background:#fff; text-align:center;
#wrapper width:auto; border:1px solid #000; min-width:770px; max-width:1024px; text-align:left; margin-left:auto; margin-right:auto; position:relative;

#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
#left
 position:relative;/*ie needs this to show float */
 width:130px;float:left;left:-1px;
 margin-left:-129px;/*must be 1px less than width otherwise won"t push footer down */

* html #left margin-right:-3px;/* 3px jog*/
* html #outer/* 3px jog*/
 margin-left:127px; margin-right:127px;
p margin-bottom:1em; padding:0 5px

#right
 position:relative;/*ie needs this to show float */
 width:130px; float:right; left:1px;
 margin-right:-129px;/*must be 1px less than width otherwise won"t push footer down */

* html #right margin-right:-130px; margin-left:-3px/* stop float drop in ie + 3px jog */

#footer width:100%; clear:both; line-height:50px; border-top:1px solid #000; background:#ffc; color:#000; text-align:center; position:relative;
#clearheader height:72px;/*needed to make room for header*/
#centrecontent float:right; width:100%; position:relative;

html>body #centrecontent margin:0 -0.5%/*moz needs this*/
.outerwrap float:left; width:99%;
.clearer height:1px; overflow:hidden; margin-top:-1px; clear:both;

/* mac hide\*/
* html #outer, * html #wrapper,* html #centrecontent height:1%
/* end hide */

</style>
<!--[if gte IE 5]>
<style type="text/css">
body width:expression( documentElement.clientWidth < 770 ? (documentElement.clientWidth == 0 ? (body.clientWidth < 770 ? "770" : "auto") : "770px") : "auto" );
#wrapper width:expression( documentElement.clientWidth > 1024 ? (documentElement.clientWidth == 0 ? (body.clientWidth >1024 ? "1024" : "auto") : "1024px") : "auto" );
</style>
<![endif]-->
</head>

<body>
<div id="wrapper">
<div id="outer">

 <div id="clearheader"></div>

 <div class="outerwrap">
 
  <div id="centrecontent">
   <h1>Min width of 770px and max width of 1024px</h1>
   <p>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 : </p>
  </div>
  
  <div id="left">
   <p>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 : </p>
  </div>
  
  <div class="clearer"></div>
  
 </div>
 
 <!--end outer wrap -->
 <div id="right">
  <p>Start Right content goes here : Right content goes here : Right content
  goes here : Right content goes here : Right content goes here : Right
  content goes here : Right content goes here : Right content goes here
  : Right content goes here : </p>
 </div>
 
 <div class="clearer"></div>

</div>

<div id="footer">Footer - | - Footer </div>
<div id="header">Header </div>

</div>
</body>
</html>

时间: 2023-12-06 16:03:01

网页最窄770px最宽1024px经典布局的相关文章

最窄770px最宽1024px经典布局

最典型实用的上中下,并且中间分三列的布局,这个例子有2个特点: 1. 中间三列效果,可以任意实现单列背景色.2. 整体最窄770px,最宽1024px,也就是说窗口小于770xp就出底部滚动条,如果大于1024px自动屏幕居中. IE6.0和FF1.5测试通过 分析: 最外层的wrapper把所有内容都嵌套在里边,整体相对定位.max min已经很好的控制了最窄最宽值,但对IE没有作用.如果没有其他布局的穿插,这一层其实写在body内就可以,少一层嵌套. #wrapper{ width:auto

最窄770px最宽1024px的经典布局

 最典型实用的上中下,并且中间分三列的布局,这个例子有2个特点: 1. 中间三列效果,可以任意实现单列背景色.2. 整体最窄770px,最宽1024px,也就是说窗口小于770xp就出底部滚动条,如果大于1024px自动屏幕居中. IE6.0和FF1.5测试通过 Demo http://www.rexsong.com/blog/attachments/200512/29_154158_minmax_3col.htm 分析: 最外层的wrapper把所有内容都嵌套在里边,整体相对定位.max mi

最窄770px最宽1024px的经典布局研究_CSS/HTML

最典型实用的上中下,并且中间分三列的布局,这个例子有2个特点: 1. 中间三列效果,可以任意实现单列背景色.2. 整体最窄770px,最宽1024px,也就是说窗口小于770xp就出底部滚动条,如果大于1024px自动屏幕居中.   效果浏览:http://www.rexsong.com/blog/attachments/200512/29_154158_minmax_3col.htm 分析: 最外层的wrapper把所有内容都嵌套在里边,整体相对定位.max min已经很好的控制了最窄最宽值,

CSS3让网页更富于表现和支持更复杂布局

文章简介:CSS3 Region:基于HTML和CSS3的富页面布局. 译自:CSS3 regions: Rich page layout with HTML and CSS3中文:CSS3 Region:基于HTML和CSS3的富页面布局请尊重版权,转载请注明来源,多谢! 互联网已经成为一个提供参考.教材.新闻.文章和交互应用的大宝库了.然而,当为印刷设计内容时,一些功能显然仍然不可能或者很难使用Web标准来实现. 印刷出版物正在探索更好的方法来转换或者改变他们的内容以适应富数字格式.我们也看

网页上的摄影展:等高响应布局实现

「等高响应式布局」是什么?介绍它之前,我们先回忆一下它的近亲「等宽响应式瀑布流」. 回忆一下,Pinterest.Google+.花瓣网.美丽说等是否让你沉浸于不断往下拉体验丰富的图片阅览? 那种感觉就像逛街,让所有商品呈现在网页上,只需要往下拉鼠标就能逐个浏览,不断加载,他们简洁同时整齐,原因是他们的宽度相等,但是高度不一. 这就是所谓的「等宽响应式瀑布流」,它的特点如下: 1.响应式,适应PC端以及移动端各设备呈现不同的宽度和单列数量; 2.等宽,这样的布局十分适合瀑布流,有不断向下的阅读感

SEO参考:DIV+CSS三行两列经典布局

中介交易 http://www.aliyun.com/zixun/aggregation/6858.html">SEO诊断 淘宝客 云主机 技术大厅 这个XHTML1标准的DIV+CSS布局是著名网页设计师阿捷2004年发布在<网页设计师>上的,一个非常经典的布局,在IE.Mozilla和Opera浏览器中均可以实现居中和高度自适应. 这个XHTML1标准的DIV+CSS布局是著名网页设计师阿捷2004年发布在<网页设计师>上的,一个非常经典的布局,在IE.Mozi

DIV+CSS三行两列经典布局

中介交易 http://www.aliyun.com/zixun/aggregation/6858.html">SEO诊断 淘宝客 云主机 技术大厅 这个XHTML1标准的DIV+CSS布局是著名网页设计师阿捷2004年发布在<网页设计师 >上的,一个非常经典的布局,在IE.Mozilla和Opera浏览器中均可以实现居中和高度自适应.完整代码如下(在原代码的基础上作了一定规范整理):           <html>   <head>   <me

PS网页设计教程VIII——在Photoshop中设计不同寻常布局

作为编码者,美工基础是偏弱的.我们可以参考一些成熟的网页PS教程,提高自身的设计能力.套用一句话,"熟读唐诗三百首,不会作诗也会吟". 本系列的教程来源于网上的PS教程,都是国外的,全英文的.本人尝试翻译这些优秀的教程.因为翻译能力有限,翻译的细节上还有待推敲,希望广大网友不吝赐教. 约定: 1.本文的软件是Photoshop CS5版本 2.原教程的截图是英文的,本人在重新制作的基础上,重新截了中文版的图 3.原文中有些操作没有给出参数.本人在反复测试的情况下测定了一些参数,以红色的

常用网站经典布局实例

网页布局有很多布局模式如单行一列,两行一列,三行一列,传统的三行两列布局,各种布局,今天就来一个大集合,大放送..... 单行一列 以下是引用片段: body { margin: 0px; padding: 0px; text-align: center; }  #content { margin-left:auto; margin-right:auto; width: 400px; width: 370px; }       两行一列 以下是引用片段: body { margin: 0px;