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

2016-02-19 13:28 32 1 收藏

今天图老师小编给大家介绍下网页最窄770px最宽1024px经典布局,平时喜欢网页最窄770px最宽1024px经典布局的朋友赶紧收藏起来吧!记得点赞哦~

【 tulaoshi.com - Web开发 】

最典型实用的上中下,并且中间分三列的布局,这个例子有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。

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/webkaifa/)

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

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/webkaifa/)

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="te

es 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"
   pLeft 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"
  pStart 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

来源:https://www.tulaoshi.com/n/20160219/1604427.html

延伸阅读
标签: Web开发
嗯,开场先胡扯几句不相关地感言。最近的工作让我有了很多实践的机会,同时也让我收获颇丰。在群里聊天的时候也提到过,所有的学习过程,最好是理论-实践-再理论-再实践。。。的一个循环往复的过程。这里说的理论是个比较宽泛地概念,其中包括书本理论,也包括对实践地总结。只有理论没有实践,往往造成眼高手低,想得好,做得差;只一味...
标签: 奶油 洋葱 香辣虾
香辣牛肉面 1.将己煮熟的牛肉切成小块备用。 2.面、青菜烫熟放进碗内备用。 3.酸辣牛肉汤头以调味料调味,放入牛肉块,再倒入作法2的碗�即可。 香辣牛肉粒 1、牛肉切粗条或粒,用清水浸泡1小时。 2、干辣椒剪成段,葱切段,姜切片。 3、将牛肉的水分挤干,血水倒掉,加入料酒,再加入1/2茶匙盐。 4、放入葱段和姜片,抓匀腌制30...
标签: Web开发
在一个国外网站看到的12种常见的div+css布局模板,是可以根据屏幕分辨路自适应宽度的动态布局,感觉很好。                                菜单和内容动态    &nb...
标签: 生活常识
1.8米宽的超窄长方屋 1.8米宽的超窄长方屋 座落在日本东京市的丰岛区,「1.8M Width House」是由 YUUA 建筑设计事务所带来的一幢狭长的长方体住宅,真正实如其名的只有1.8米的宽度。整幢房屋甚至可说就是在相邻两幢房屋间的「走道」上拨地而起,超过一米八的人都无法在住宅内完全的横着躺下 。在面向街道的正面 ,设计师创...

经验教程

410

收藏

83
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部