CSS 常用经典布局 - 三栏布局效果展示原始效果最终效果原始代码html 部分12345<div class="container"> <div class="left">left</div> <div class="center">center</div> <div class="right">right</div></div>css 部分123456789101112131415161718192021222324body { min-width: 630px; margin: 0;}.left,.center,.right { height: 150px;}.left { width: 100px; background-color: #ffb5bf;}.center { background-color: #94e8ff;}.right { width: 200px; background-color: #8990d5;}实现方法flex 布局1234567.container { display: flex;}.center { flex: 1;}grid 布局1234.container { display: grid; grid-template-columns: 100px 1fr 200px;}table 布局12345678910.container { width: 100%; display: table;}.left,.center,.right { display: table-cell;}定位布局12345678910111213141516171819.container { position: relative;}.left { position: absolute; left: 0;}.center { position: absolute; left: 100px; right: 200px;}.right { position: absolute; right: 0;}浮动布局12345<div class="container"> <div class="left">left</div> <div class="right">right</div> <div class="center">center</div></div>1234567891011.container { overflow: hidden;}.left { float: left;}.right { float: right;}圣杯布局12345<div class="container"> <div class="center">center</div> <div class="left">left</div> <div class="right">right</div></div>123456789101112131415161718192021222324252627.container { overflow: hidden; padding-left: 100px; padding-right: 200px;}.center,.left,.right { float: left;}.center { width: 100%;}.left { position: relative; left: -100px; margin-left: -100%;}.right { position: relative; right: -200px; margin-left: -200px;}双飞翼布局1234567<div class="container"> <div class="center-container"> <div class="center">center</div> </div> <div class="left">left</div> <div class="right">right</div></div>1234567891011121314151617181920212223242526.container { overflow: hidden;}.center-container,.left,.right { float: left;}.center-container { width: 100%;}.center-container .center { margin-left: 100px; margin-right: 200px;}.left { margin-left: -100%;}.right { margin-left: -200px;} CSS实用技巧 #CSS #三栏布局CSS 常用经典布局 - 三栏布局https://blog.xukaiyyds.cn/posts/1db87a14/作者xukaiyyds发布于2023年2月11日许可协议 CSS 实现盒子水平垂直居中的方法 上一篇CSS 常用经典布局 - 两栏布局 下一篇 Please enable JavaScript to view the comments