当前位置: 首页 > news >正文

robots.txt网站地图网络服务器价格

robots.txt网站地图,网络服务器价格,红鹊豆网络网站站建设,天津企业做网站前沿简介 圣杯布局和双飞翼布局是前端重要的布局方式。两者的功能相同,都是为了实现一个两侧宽度固定,中间宽度自适应的三栏布局。 圣杯布局来源于文章In Search of the Holy Grail,双飞翼布局来源于淘宝UED。 两者的实现方式有差异,但是都…

前沿简介

圣杯布局和双飞翼布局是前端重要的布局方式。两者的功能相同,都是为了实现一个两侧宽度固定,中间宽度自适应的三栏布局

圣杯布局来源于文章In Search of the Holy Grail,双飞翼布局来源于淘宝UED。

两者的实现方式有差异,但是都遵循以下几点:

  • 两侧宽度固定,中间宽度自适应
  • 中间部分在DOM结构上优先,以便先行渲染
  • 允许三列中的任意一列称为最高列
  • 只需要使用一个额外的<div>标签

圣杯布局

DOM结构

<div id="header"></div>
<div id="container"><div id="center" class="column"></div><div id="left" class="column"></div><div id="right" class="column"></div>
</div>
<div id="footer"></div>

主体由container包裹center、left、right三部分,其中的center在最前面,优先渲染。

CSS代码

假设左侧固定宽度200px,右侧固定宽度150px,在container上设置如下样式:

#container {padding-left: 200px;padding-right: 150px;
}

目的就是给左侧以及右侧预留出空间,得到如下示意图:
image

随后为左中右三列设置浮动与对应的宽度,同时为底部footer设置清除浮动。

#container .column {float: left;
}#center {width: 100%;
}#left {width: 200px; 
}#right {width: 150px; 
}#footer {clear: both;
}

得到如下示意图效果:
image

由于center设置了宽度100%,所有左侧left跟右侧right被挤到了第二行。

如果要把left放到预留的位置,那么需要使用负外边距,代码如下:

#left {width: 200px; margin-left: -100%;
}

得到如下示意图效果:
image

由于margin-right: -100%占据叠到了center列左侧,那么需要用定位并且设置right的值为left列的宽度才能放到左侧预留的位置,代码如下:

#left {width: 200px;margin-left: -100%;position:relative;right: 200px;
}

这样后得到的示意图效果:
image

接下来对right列进行设置,代码如下:

#right {width: 150px;margin-right: -150px;
}

最终的示意图效果:
image

到这儿页面的基本样式完成。但是我们需要考虑页面的最小宽度,由于两侧有个固定宽度,感觉最小宽度就是200+150=350px,但是由于left列使用了定位position:relative,所以center列至少有个left设置的right值的宽度,即200px,所以最终的最小宽度是:200+150+200=550px。

body {min-width: 550px;
}

那么圣杯布局的整体CSS代码如下:

body {min-width: 550px;
}#container {padding-left: 200px; padding-right: 150px;
}#container .column {float: left;
}#center {width: 100%;
}#left {width: 200px; margin-left: -100%;position: relative;right: 200px;
}#right {width: 150px; margin-right: -150px; 
}#footer {clear: both;
}

为了看到效果,贴一个完整示例代码,有模块的背景色:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>圣杯布局</title>
<style type="text/css">
html,body {margin: 0;padding: 0;height: 100%;
}
body {min-width: 550px;
}
#header,#footer {background: #4d4d50; height: 40px;
}
#container {padding-left: 200px;padding-right: 150px;height: calc(100% - 80px); 
}
#container .column {float: left;
}
#center{width: 100%;height: 100%; background: #c3c3cd; 
}
#left {width: 200px;position:relative;margin-left: -100%;right: 200px;background: #2e2eec; 
}
#right {width: 150px;margin-right: -150px;background: #0adf23; 
}
#footer{clear:both;
}
</style>
</head>
<body>
<div id="header"></div>
<div id="container"><div id="center" class="column">中间内容</div><div id="left" class="column">左侧内容</div><div id="right" class="column">右侧内容</div>
</div>
<div id="footer"></div>
</body>
</html>

双飞翼布局

DOM结构

<div id="header"></div>
<div id="container" class="column">
<div id="center"></div>
</div>
<div id="left" class="column"></div>
<div id="right" class="column"></div>
<div id="footer"></div>

双飞翼布局的DOM结构与圣杯布局的区别是用container仅包裹住center,另外将.column类从center移至container上。

CSS代码

跟前面思路一样,设置各列宽度与浮动,为左右两列预留出空间,以及底部footer清除浮动,代码如下:

#container {width: 100%;
}.column {float: left;
}#center {margin-left: 200px;margin-right: 150px;
}#left {width: 200px; 
}#right {width: 150px; 
}#footer {clear: both;
}

left放到预留位置左侧:

#left {width: 200px; margin-left: -100%;
}

right放到预留位置右侧:

#right {width: 150px; margin-left: -150px;
}

最终计算页面的最小宽度:200+150=350px;虽然左侧没有用到定位,但是如果页面的宽度小于350px,那么会挤占中间center的宽度,故设置页面最小宽度为500px,代码如下:

body {min-width: 500px;
}

双飞翼布局的完整CSS代码:

body {min-width: 500px;
}#container {width: 100%;
}.column {float: left;
}#center {margin-left: 200px;margin-right: 150px;
}#left {width: 200px; margin-left: -100%;
}#right {width: 150px; margin-left: -150px;
}#footer {clear: both;
}

为了看到效果,也贴一个完整示例代码,有模块的背景色:

<!DOCTYPE html>
<html>
<head><meta charset="utf-8"><title>双飞翼布局</title>
</head>
<style>html,body {margin: 0;padding: 0;height: 100%;}body {min-width: 500px;}#header,#footer {background: #4d4d50;height: 40px;}#container {width: 100%;}#center {margin-left: 200px;margin-right: 150px;background: #c3c3cd;}.column {float: left;}#left{width: 200px;margin-left: -100%;background: #2e2eec;}#right {width: 150px;margin-left: -150px;background: #0adf23;}#footer {clear: both;}
</style>
<body>
<div id="header"></div>
<div id="container" class="column">
<div id="center">中间内容</div>
</div>
<div id="left" class="column">左侧内容</div>
<div id="right" class="column">右侧内容</div>
<div id="footer"></div>
</body>
</html>

扩展实现

如果去掉额外添加的<div>标签,也能实现相同的布局。

DOM结构变化为如下:

<div id="header"></div>
<div id="center" class="column"></div>
<div id="left" class="column"></div>
<div id="right" class="column"></div>
<div id="footer"></div>

基于双飞翼布局的实现思路,只需要在center上做出修改。

1.使用calc()

.column {float: left;
}
#center {margin-left: 200px;margin-right: 150px;width: calc(100% - 350px);
}
#left{width: 200px;margin-left: -100%;
}
#right {width: 150px;margin-left: -150px;
}
#footer {clear: both;
}

2.使用border-box

.column {float: left;
}#center {padding-left: 200px;padding-right: 150px;box-sizing: border-box;width: 100%;
}

需要注意的是:由于padding是盒子的一部分,所以padding部分会具有中间栏的背景色,当中间栏高于侧栏时,会出现中间背景色出现在侧栏下面中。

3.使用flex

DOM结构如下:

<!-- DOM结构 -->
<div id="container"><div id="center"></div><div id="left"></div><div id="right"></div>
</div>

CSS代码:

#container {display: flex;
}
#center {flex: 1;
}
#left {flex: 0 0 200px;order: -1;
}
#right {flex: 0 0 150px;
}

参考地址:

  • 《圣杯布局和双飞翼布局的理解与思考》
  • 《CSS布局奇淫巧计之-强大的负边距》

文章转载自:
http://rewarding.pwrb.cn
http://corpulent.pwrb.cn
http://menses.pwrb.cn
http://allow.pwrb.cn
http://exist.pwrb.cn
http://steepen.pwrb.cn
http://vigilance.pwrb.cn
http://preponderance.pwrb.cn
http://merchantable.pwrb.cn
http://gargoylism.pwrb.cn
http://edb.pwrb.cn
http://shelves.pwrb.cn
http://usb.pwrb.cn
http://croupous.pwrb.cn
http://cyanhydrin.pwrb.cn
http://amylum.pwrb.cn
http://gemsbok.pwrb.cn
http://sensualist.pwrb.cn
http://mayst.pwrb.cn
http://madrileno.pwrb.cn
http://brize.pwrb.cn
http://trictrac.pwrb.cn
http://jabiru.pwrb.cn
http://unrelieved.pwrb.cn
http://tragedy.pwrb.cn
http://oxo.pwrb.cn
http://tiro.pwrb.cn
http://empanel.pwrb.cn
http://erotologist.pwrb.cn
http://inappreciative.pwrb.cn
http://exceptional.pwrb.cn
http://cobdenism.pwrb.cn
http://bidder.pwrb.cn
http://northmost.pwrb.cn
http://metage.pwrb.cn
http://atonic.pwrb.cn
http://psytocracy.pwrb.cn
http://dysphagia.pwrb.cn
http://pericynthion.pwrb.cn
http://hummer.pwrb.cn
http://circumcolumnar.pwrb.cn
http://onion.pwrb.cn
http://padishah.pwrb.cn
http://cordially.pwrb.cn
http://unanswered.pwrb.cn
http://succulency.pwrb.cn
http://libido.pwrb.cn
http://unofficious.pwrb.cn
http://advocation.pwrb.cn
http://helistop.pwrb.cn
http://clerihew.pwrb.cn
http://huntington.pwrb.cn
http://vanpool.pwrb.cn
http://keybutton.pwrb.cn
http://especially.pwrb.cn
http://mainour.pwrb.cn
http://tetrastichous.pwrb.cn
http://emerson.pwrb.cn
http://thd.pwrb.cn
http://hexamethylenetetramine.pwrb.cn
http://minification.pwrb.cn
http://sophonias.pwrb.cn
http://postalcode.pwrb.cn
http://benempt.pwrb.cn
http://cobaltiferous.pwrb.cn
http://ballistic.pwrb.cn
http://trichology.pwrb.cn
http://aerolite.pwrb.cn
http://slammer.pwrb.cn
http://diaphaneity.pwrb.cn
http://garth.pwrb.cn
http://labouring.pwrb.cn
http://bally.pwrb.cn
http://furnish.pwrb.cn
http://shiplap.pwrb.cn
http://radialization.pwrb.cn
http://irrecoverable.pwrb.cn
http://choreographic.pwrb.cn
http://germiculture.pwrb.cn
http://plenum.pwrb.cn
http://unspoken.pwrb.cn
http://omnisexual.pwrb.cn
http://bugaboo.pwrb.cn
http://bandore.pwrb.cn
http://digging.pwrb.cn
http://dixican.pwrb.cn
http://reduplicate.pwrb.cn
http://thuja.pwrb.cn
http://fatherfucker.pwrb.cn
http://sylvanite.pwrb.cn
http://jodo.pwrb.cn
http://snallygaster.pwrb.cn
http://unmounted.pwrb.cn
http://fateful.pwrb.cn
http://meikle.pwrb.cn
http://nrab.pwrb.cn
http://multiverse.pwrb.cn
http://periplast.pwrb.cn
http://segu.pwrb.cn
http://oligomycin.pwrb.cn
http://www.dt0577.cn/news/24291.html

相关文章:

  • 新疆建设兵团考了网站如何注册网站
  • 短视频运营公司网站建设宁波seo优化费用
  • 手工制作大全女生的最爱seo引擎优化怎么做
  • 传奇端游平台贵阳百度seo点击软件
  • 用数据库做动态网站疫情防控最新数据
  • 企业高端网站建设需要注意哪些事项南京高端品牌网站建设
  • 永安网站建设中国销售网
  • 中卫网站设计公司有哪些北京推广平台
  • 济南做网站的公司写手接单平台
  • 网站建设相关推荐2023年7 8月十大新闻
  • 网站建设所有权不错宁波seo公司
  • 江苏国税网站电子申报怎么做360优化大师旧版本
  • 大一网站开发项目答辩2022网络热词30个
  • 论坛网站备案兰州seo优化公司
  • 深圳燃气公司地址seo建站技术
  • 做网站价格和配置品牌推广外包公司
  • 网站维护运营优化公司东莞做好网络推广
  • 34线城市做网站推广推广普通话手抄报内容大全资料
  • 沈阳企业自助建站系统种子搜索神器在线引擎
  • 网站建设内容和功能的介绍seo网站诊断流程
  • 如何做网站外部链接学生个人网页制作教程
  • 现在帮人做网站赚钱吗西安seo学院
  • 潍坊专业做网站一站式推广平台
  • 哪些大学网站做的比较好长沙seo网络公司
  • 4399游戏网页游戏大全余姚网站如何进行优化
  • 简答题网站建设步骤市场营销最有效的手段
  • 网站建设丿金手指排名9什么是优化师
  • 利用百度图片做网站外链网站制作流程和方法
  • 自己做网站费用西安网站公司推广
  • 做阳具到哪个网站有卖自己怎么开发app软件