一、两侧定宽中间自适应布局
思路一: float
【1】float + margin + calc
CSS Code复制内容到剪贴板- <style>
- p{margin: 0;}
- .parent{overflow: hidden;}
- .left,.rightright{float: left;width: 100px;}
- .center{float: left; width:calc(100% - 240px);margin: 0 20px;}
- </style>
- <div class="parent" style="background-color: lightgrey;">
- <div class="left" style="background-color: lightblue;">
- <p>left</p>
- </div>
- <div class="center" style="background-color: pink;">
- <p>center</p>
- <p>center</p>
- </div>
- <div class="right" style="background-color: lightgreen;">
- <p>right</p>
- </div>
- </div>
【2】float + margin + (fix)
CSS Code复制内容到剪贴板- <style>
- p{margin: 0;}
- .parent{overflow: hidden;}
- .left,.rightright{position: relative;float: left;width: 100px;}
- .centerWrap{float: left; width:100%; margin: 0 -100px;}
- .center{margin: 0 120px;}
- </style>
- <div class="parent" style="background-color: lightgrey;">
- <div class="left" style="background-color: lightblue;">
- <p>left</p>
- </div>
- <div class="centerWrap" style="background-color: red;">
- <div class="center" style="background-color: pink;">
- <p>center</p>
- <p>center</p>
- </div>
- </div>
- <div class="right" style="background-color: lightgreen;">
- <p>right</p>
- </div>
- </div>
思路二: inline-block
【1】inline-block + margin + calc
CSS Code复制内容到剪贴板- <style>
- p{margin: 0;}
- .parent{font-size: 0;}
- .left,.rightright,.center{display:inline-block; vertical-align: top;font-size: 16px;}
- .left,.rightright{width: 100px;}
- .center{width: calc(100% - 240px); margin: 0 20px;}
- </style>
- <div class="parent" style="background-color: lightgrey;">
- <div class="left" style="background-color: lightblue;">
- <p>left</p>
- </div>
- <div class="center" style="background-color: pink;">
- <p>center</p>
- <p>center</p>
- </div>
- <div class="right" style="background-color: lightgreen;">
- <p>right</p>
- </div>
- </div>
【2】inline-block + margin + (fix)
CSS Code复制内容到剪贴板- <style>
- p{margin: 0;}
- .parent{font-size: 0;}
- .left,.rightright,.centerWrap{display:inline-block; vertical-align: top;font-size: 16px;}
- .left,.rightright{width: 100px;position:relative;}
- .centerWrap{width: 100%; margin: 0 -100px;}
- .center{margin: 0 120px;}
- </style>
- <div class="parent" style="background-color: lightgrey;">
- <div class="left" style="background-color: lightblue;">
- <p>left</p>
- </div>
- <div class="centerWrap" style="background-color: orange;">
- <div class="center" style="background-color: pink;">
- <p>center</p>
- <p>center</p>
- </div>
- </div>
- <div class="right" style="background-color: lightgreen;">
- <p>right</p>
- </div>
- </div>
思路三: table
CSS Code复制内容到剪贴板- <style>
- p{margin: 0;}
- .parent{display: table; width: 100%;table-layout: fixed;}
- .left,.rightright,.centerWrap{display:table-cell;}
- .left,.rightright{width: 100px;}
- .center{margin: 0 20px;}
- </style>
- <div class="parent" style="background-color: lightgrey;">
- <div class="left" style="background-color: lightblue;">
- <p>left</p>
- </div>
- <div class="centerWrap" style="background-color: orange;">
- <div class="center" style="background-color: pink;">
- <p>center</p>
- <p>center</p>
- </div>
- </div>
- <div class="right" style="background-color: lightgreen;">
- <p>right</p>
- </div>
- </div>
思路四: absolute
CSS Code复制内容到剪贴板- <style>
- p{margin: 0;}
- .parent{position: relative;height:40px;}
- .left,.rightright,.center{position: absolute;}
- .left{left: 0;width:100px;}
- .rightright{rightright: 0;width: 100px;}
- .center{left: 120px; rightright: 120px;}
- </style>
- <div class="parent" style="background-color: lightgrey;">
- <div class="left" style="background-color: lightblue;">
- <p>left</p>
- </div>
- <div class="center" style="background-color: pink;">
- <p>center</p>
- <p>center</p>
- </div>
- <div class="right" style="background-color: lightgreen;">
- <p>right</p>
- </div>
- </div>
思路五: flex
CSS Code复制内容到剪贴板- <style>
- p{margin: 0;}
- .parent{display: flex;}
- .left,.rightright{width: 100px;}
- .center{flex: 1; margin: 0 20px;}
- </style>
- <div class="parent" style="background-color: lightgrey;">
- <div class="left" style="background-color: lightblue;">
- <p>left</p>
- </div>
- <div class="center" style="background-color: pink;">
- <p>center</p>
- <p>center</p>
- </div>
- <div class="right" style="background-color: lightgreen;">
- <p>right</p>
- </div>
- </div>
二、两列定宽一侧自适应布局
这种布局与单列定宽单列自适应布局非常相似
思路一: float
【1】float + margin
缺点是IE6-浏览器的3px的bug,以及当自适应列中有元素清除浮动时,会使该元素不与左侧浮动元素同行,从而出现文字下沉现象
CSS Code复制内容到剪贴板- <style>
- p{margin: 0;}
- .parent{overflow: hidden;}
- .left,.center{float: left;width: 100px;margin-right: 20px;}
- .rightright{margin-left: 240px;}
- </style>
- <div class="parent" style="background-color: lightgrey;">
- <div class="left" style="background-color: lightblue;">
- <p>left</p>
- </div>
- <div class="center" style="background-color: pink;">
- <p>center</p>
- </div>
- <div class="right" style="background-color: lightgreen;">
- <p>right</p>
- <p>right</p>
- </div>
- </div>
【2】float + margin + calc
CSS Code复制内容到剪贴板- <style>
- p{margin: 0;}
- .parent{overflow: hidden;}
- .left,.center{float: left;width: 100px;margin-right: 20px;}
- .rightright{float: left; width: calc(100% - 240px);}
- </style>
- <div class="parent" style="background-color: lightgrey;">
- <div class="left" style="background-color: lightblue;">
- <p>left</p>
- </div>
- <div class="center" style="background-color: pink;">
- <p>center</p>
- </div>
- <div class="right" style="background-color: lightgreen;">
- <p>right</p>
- <p>right</p>
- </div>
- </div>
【3】float + margin + (fix)
CSS Code复制内容到剪贴板- <style>
- p{margin: 0;}
- .parent{overflow: hidden;}
- .left,.center{position: relative; float: left;width: 100px;margin-right: 20px;}
- .rightWrap{float: left; width: 100%; margin-left: -240px;}
- .rightright{margin-left:240px;}
- </style>
- <div class="parent" style="background-color: lightgrey;">
- <div class="left" style="background-color: lightblue;">
- <p>left</p>
- </div>
- <div class="center" style="background-color: pink;">
- <p>center</p>
- </div>
- <div class="rightWrap">
- <div class="right" style="background-color: lightgreen;">
- <p>right</p>
- <p>right</p>
- </div>
- </div>
- </div>
【4】float + overflow
CSS Code复制内容到剪贴板- <style>
- p{margin: 0;}
- .parent{overflow: hidden;}
- .left,.center{position: relative; float: left;width: 100px;margin-right: 20px;}
- .rightright{overflow: hidden;zoom:1;}
- </style>
- <div class="parent" style="background-color: lightgrey;">
- <div class="left" style="background-color: lightblue;">
- <p>left</p>
- </div>
- <div class="center" style="background-color: pink;">
- <p>center</p>
- </div>
- <div class="right" style="background-color: lightgreen;">
- <p>right</p>
- <p>right</p>
- </div>
- </div>
思路二: inline-block
【1】inline-block + margin + calc
CSS Code复制内容到剪贴板- <style>
- p{margin: 0;}
- .parent{font-size: 0;}
- .left,.rightright,.center{display:inline-block; vertical-align: top;font-size: 16px;}
- .left,.center{width: 100px;margin-right:20px;}
- .rightright{width: calc(100% - 240px);}
- </style>
- <div class="parent" style="background-color: lightgrey;">
- <div class="left" style="background-color: lightblue;">
- <p>left</p>
- </div>
- <div class="center" style="background-color: pink;">
- <p>center</p>
- </div>
- <div class="right" style="background-color: lightgreen;">
- <p>right</p>
- <p>right</p>
- </div>
- </div>
【2】inline-block + margin + (fix)
XML/HTML Code复制内容到剪贴板- <style>
- p{margin: 0;}
- .parent{font-size: 0;}
- .left,.rightWrap,.center{display:inline-block; vertical-align: top;font-size: 16px;}
- .left,.center{position: relative;width: 100px;margin-right:20px;}
- .rightWrap{width:100%; margin-left: -240px;}
- .right{margin-left: 240px;}
- </style>
- <div class="parent" style="background-color: lightgrey;">
- <div class="left" style="background-color: lightblue;">
- <p>left</p>
- </div>
- <div class="center" style="background-color: pink;">
- <p>center</p>
- </div>
- <div class="rightWrap" style="background-color: green;">
- <div class="right" style="background-color: lightgreen;">
- <p>right</p>
- <p>right</p>
- </div>
- </div>
- </div>
思路三: table
CSS Code复制内容到剪贴板- <style>
- p{margin: 0;}
- .parent{display: table; width: 100%;table-layout: fixed;}
- .leftWrap,.centerWrap,.rightright{display:table-cell;}
- .leftWrap,.centerWrap{width: 120px;}
- .left,.center{margin-right: 20px;}
- </style>
- <div class="parent" style="background-color: lightgrey;">
- <div class="leftWrap">
- <div class="left" style="background-color: lightblue;">
- <p>left</p>
- </div>
- </div>
- <div class="centerWrap">
- <div class="center" style="background-color: pink;">
- <p>center</p>
- </div>
- </div>
- <div class="right" style="background-color: lightgreen;">
- <p>right</p>
- <p>right</p>
- </div>
- </div>
思路四: absolute
CSS Code复制内容到剪贴板- <style>
- p{margin: 0;}
- .parent{position: relative;width:100%;height:40px;}
- .left{position: absolute;left:0;width:100px;}
- .center{position: absolute;left:120px;width: 100px;}
- .rightright{position: absolute;left:240px; rightright:0;}
- </style>
- <div class="parent" style="background-color: lightgrey;">
- <div class="left" style="background-color: lightblue;">
- <p>left</p>
- </div>
- <div class="center" style="background-color: pink;">
- <p>center</p>
- </div>
- <div class="right" style="background-color: lightgreen;">
- <p>right</p>
- <p>right</p>
- </div>
- </div>
思路五: flex
CSS Code复制内容到剪贴板- <style>
- p{margin: 0;}
- .parent{display: flex;}
- .left,.center{width:100px;margin-right:20px;}
- .rightright{flex:1;}
- </style>
- <div class="parent" style="background-color: lightgrey;">
- <div class="left" style="background-color: lightblue;">
- <p>left</p>
- </div>
- <div class="center" style="background-color: pink;">
- <p>center</p>
- </div>
- <div class="right" style="background-color: lightgreen;">
- <p>right</p>
- <p>right</p>
- </div>
- </div>
三、中间定宽两侧自适应布局
思路一: float
CSS Code复制内容到剪贴板- <style>
- p{margin: 0;}
- .parent{overflow: hidden;}
- .left{float: left;margin-right: 20px;}
- .center{float: left;width: 100px;margin-right: 20px;}
- .rightright{overflow: hidden;}
- </style>
- <div class="parent" style="background-color: lightgrey;">
- <div class="left" style="background-color: lightblue;">
- <p>left</p>
- <p>left</p>
- </div>
- <div class="center" style="background-color: pink;">
- <p>center</p>
- </div>
- <div class="right" style="background-color: lightgreen;">
- <p>right</p>
- <p>right</p>
- </div>
- </div>
思路二: table
CSS Code复制内容到剪贴板- <style>
- p{margin: 0;}
- .parent{display: table; width: 100%;}
- .leftWrap{display: table-cell; width: 0.1%;}
- .centerWrap{display: table-cell;width: 120px;}
- .left,.center{margin-right: 20px;}
- .rightright{display:table-cell;}
- </style>
- <div class="parent" style="background-color: lightgrey;">
- <div class="leftWrap">
- <div class="left" style="background-color: lightblue;">
- <p>left</p>
- <p>left</p>
- </div>
- </div>
- <div class="centerWrap">
- <div class="center" style="background-color: pink;">
- <p>center</p>
- </div>
- </div>
- <div class="right" style="background-color: lightgreen;">
- <p>right</p>
- <p>right</p>
- </div>
- </div>
思路三: flex
CSS Code复制内容到剪贴板- <style>
- p{margin: 0;}
- .parent{display: flex;}
- .left{margin-right: 20px;}
- .center{width: 100px;margin-right: 20px;}
- .rightright{flex: 1;}
- </style>
- <div class="parent" style="background-color: lightgrey;">
- <div class="left" style="background-color: lightblue;">
- <p>left</p>
- <p>left</p>
- </div>
- <div class="center" style="background-color: pink;">
- <p>center</p>
- </div>
- <div class="right" style="background-color: lightgreen;">
- <p>right</p>
- <p>right</p>
- </div>
- </div>
四、一侧定宽两列自适应布局
思路一: float
CSS Code复制内容到剪贴板- <style>
- p{margin: 0;}
- .parent{overflow: hidden;}
- .left{float: left;width: 100px;margin-right: 20px;}
- .center{float: left;margin-right: 20px;}
- .rightright{overflow: hidden;}
- </style>
- <div class="parent" style="background-color: lightgrey;">
- <div class="left" style="background-color: lightblue;">
- <p>left</p>
- </div>
- <div class="center" style="background-color: pink;">
- <p>center</p>
- <p>center</p>
- </div>
- <div class="right" style="background-color: lightgreen;">
- <p>right</p>
- <p>right</p>
- </div>
- </div>
思路二: table
CSS Code复制内容到剪贴板- <style>
- p{margin: 0;}
- .parent{display: table; width: 100%;}
- .leftWrap{display: table-cell; width: 120px;}
- .centerWrap{display: table-cell;width: 0.1%;}
- .left,.center{margin-right: 20px;}
- .rightright{display:table-cell;}
- </style>
- <div class="parent" style="background-color: lightgrey;">
- <div class="leftWrap">
- <div class="left" style="background-color: lightblue;">
- <p>left</p>
- </div>
- </div>
- <div class="centerWrap">
- <div class="center" style="background-color: pink;">
- <p>center</p>
- <p>center</p>
- </div>
- </div>
- <div class="right" style="background-color: lightgreen;">
- <p>right</p>
- <p>right</p>
- </div>
- </div>
思路三: flex
CSS Code复制内容到剪贴板- <style>
- p{margin: 0;}
- .parent{display: flex;}
- .left{width: 100px;margin-right: 20px;}
- .center{margin-right: 20px;}
- .rightright{flex: 1;}
- </style>
- <div class="parent" style="background-color: lightgrey;">
- <div class="left" style="background-color: lightblue;">
- <p>left</p>
- </div>
- <div class="center" style="background-color: pink;">
- <p>center</p>
- <p>center</p>
- </div>
- <div class="right" style="background-color: lightgreen;">
- <p>right</p>
- <p>right</p>
- </div>
- </div>
五、三列自适应布局
思路一: float
CSS Code复制内容到剪贴板- <style>
- p{margin: 0;}
- .parent{overflow: hidden;}
- .left,.center{float: left;margin-right: 20px;}
- .rightright{overflow: hidden;}
- </style>
- <div class="parent" style="background-color: lightgrey;">
- <div class="left" style="background-color: lightblue;">
- <p>left</p>
- <p>left</p>
- </div>
- <div class="center" style="background-color: pink;">
- <p>center</p>
- <p>center</p>
- </div>
- <div class="right" style="background-color: lightgreen;">
- <p>right</p>
- <p>right</p>
- </div>
- </div>
思路二: table
CSS Code复制内容到剪贴板- <style>
- p{margin: 0;}
- .parent{display: table; width: 100%;}
- .leftWrap,.centerWrap{display: table-cell;width: 0.1%;}
- .left,.center{margin-right: 20px;}
- .rightright{display:table-cell;}
- </style>
- <div class="parent" style="background-color: lightgrey;">
- <div class="leftWrap">
- <div class="left" style="background-color: lightblue;">
- <p>left</p>
- <p>left</p>
- </div>
- </div>
- <div class="centerWrap">
- <div class="center" style="background-color: pink;">
- <p>center</p>
- <p>center</p>
- </div>
- </div>
- <div class="right" style="background-color: lightgreen;">
- <p>right</p>
- <p>right</p>
- </div>
- </div>
-
思路三: flex
CSS Code复制内容到剪贴板- <style>
- p{margin: 0;}
- .parent{display: flex;}
- .left,.center{margin-right: 20px;}
- .rightright{flex: 1;}
- </style>
- <div class="parent" style="background-color: lightgrey;">
- <div class="left" style="background-color: lightblue;">
- <p>left</p>
- <p>left</p>
- </div>
- <div class="center" style="background-color: pink;">
- <p>center</p>
- <p>center</p>
- </div>
- <div class="right" style="background-color: lightgreen;">
- <p>right</p>
- <p>right</p>
- </div>
- </div>
总结
三列布局类似于大号的两列布局。无论是什么布局方式,无外乎需要应用float、inline-block、table、absolute和flex这五种布局属性,然后再配合负margin、calc()函数、bfc、增加结构等来实现布局
自适应包括两种情况:一种是宽度由内容撑开,一种是宽度自动撑满父元素剩余宽度
可实现宽度由内容撑开的属性有: float、inline、inline-block、table、table-cell、absolute、fixed和flex
可实现宽度自动撑满父元素剩余宽度的属性有: overflow(配合float)、table、flex
原文链接:http://www.cnblogs.com/xiaohuochai/p/5455905.html免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
《魔兽世界》大逃杀!60人新游玩模式《强袭风暴》3月21日上线
暴雪近日发布了《魔兽世界》10.2.6 更新内容,新游玩模式《强袭风暴》即将于3月21 日在亚服上线,届时玩家将前往阿拉希高地展开一场 60 人大逃杀对战。
艾泽拉斯的冒险者已经征服了艾泽拉斯的大地及遥远的彼岸。他们在对抗世界上最致命的敌人时展现出过人的手腕,并且成功阻止终结宇宙等级的威胁。当他们在为即将于《魔兽世界》资料片《地心之战》中来袭的萨拉塔斯势力做战斗准备时,他们还需要在熟悉的阿拉希高地面对一个全新的敌人──那就是彼此。在《巨龙崛起》10.2.6 更新的《强袭风暴》中,玩家将会进入一个全新的海盗主题大逃杀式限时活动,其中包含极高的风险和史诗级的奖励。
《强袭风暴》不是普通的战场,作为一个独立于主游戏之外的活动,玩家可以用大逃杀的风格来体验《魔兽世界》,不分职业、不分装备(除了你在赛局中捡到的),光是技巧和战略的强弱之分就能决定出谁才是能坚持到最后的赢家。本次活动将会开放单人和双人模式,玩家在加入海盗主题的预赛大厅区域前,可以从强袭风暴角色画面新增好友。游玩游戏将可以累计名望轨迹,《巨龙崛起》和《魔兽世界:巫妖王之怒 经典版》的玩家都可以获得奖励。
更新日志
- 【雨果唱片】中国管弦乐《鹿回头》WAV
- APM亚流新世代《一起冒险》[FLAC/分轨][106.77MB]
- 崔健《飞狗》律冻文化[WAV+CUE][1.1G]
- 罗志祥《舞状元 (Explicit)》[320K/MP3][66.77MB]
- 尤雅.1997-幽雅精粹2CD【南方】【WAV+CUE】
- 张惠妹.2007-STAR(引进版)【EMI百代】【WAV+CUE】
- 群星.2008-LOVE情歌集VOL.8【正东】【WAV+CUE】
- 罗志祥《舞状元 (Explicit)》[FLAC/分轨][360.76MB]
- Tank《我不伟大,至少我能改变我。》[320K/MP3][160.41MB]
- Tank《我不伟大,至少我能改变我。》[FLAC/分轨][236.89MB]
- CD圣经推荐-夏韶声《谙2》SACD-ISO
- 钟镇涛-《百分百钟镇涛》首批限量版SACD-ISO
- 群星《继续微笑致敬许冠杰》[低速原抓WAV+CUE]
- 潘秀琼.2003-国语难忘金曲珍藏集【皇星全音】【WAV+CUE】
- 林东松.1997-2039玫瑰事件【宝丽金】【WAV+CUE】