一、两侧定宽中间自适应布局
思路一: 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免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。
更新日志
- 凤飞飞《我们的主题曲》飞跃制作[正版原抓WAV+CUE]
- 刘嘉亮《亮情歌2》[WAV+CUE][1G]
- 红馆40·谭咏麟《歌者恋歌浓情30年演唱会》3CD[低速原抓WAV+CUE][1.8G]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[320K/MP3][193.25MB]
- 【轻音乐】曼托凡尼乐团《精选辑》2CD.1998[FLAC+CUE整轨]
- 邝美云《心中有爱》1989年香港DMIJP版1MTO东芝首版[WAV+CUE]
- 群星《情叹-发烧女声DSD》天籁女声发烧碟[WAV+CUE]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[FLAC/分轨][748.03MB]
- 理想混蛋《Origin Sessions》[320K/MP3][37.47MB]
- 公馆青少年《我其实一点都不酷》[320K/MP3][78.78MB]
- 群星《情叹-发烧男声DSD》最值得珍藏的完美男声[WAV+CUE]
- 群星《国韵飘香·贵妃醉酒HQCD黑胶王》2CD[WAV]
- 卫兰《DAUGHTER》【低速原抓WAV+CUE】
- 公馆青少年《我其实一点都不酷》[FLAC/分轨][398.22MB]
- ZWEI《迟暮的花 (Explicit)》[320K/MP3][57.16MB]