当前位置:网站首页>Three column layout (fixed width on both sides in the middle and fixed width on both sides in the middle)
Three column layout (fixed width on both sides in the middle and fixed width on both sides in the middle)
2022-04-23 03:29:00 【nknmn_】
Catalog
One . Fixed width on both sides and adaptive in the middle
Two . Fixed width in the middle and adaptive on both sides
Three column layout
One . Fixed width on both sides and adaptive in the middle
1.flex Layout
<div class="container">
<div class="left">left</div>
<div class="center">center</div>
<div class="right">right</div>
</div>
<style>
div{
height: 100px;
}
.container{
display: flex;
}
.center{
flex: 1;
background-color: blue;
}
.left,.right{
width: 100px;
background-color: red;
}
</style>
2. float + margin
<div class="container">
<div class="left">left</div>
<div class="right">right</div>
<div class="center">center</div> <!-- Note that this time center At the back -->
</div>
<style>
div{
height: 100px;
}
.left{
float: left;
width: 100px;
background-color: red;
}
.center{
margin: 0 100px;
background-color: blue;
}
.right{
float: right;
width: 100px;
background-color: red;
}
</style>
3. float + calc()
<div class="container">
<div class="left">left</div>
<div class="center">center</div>
<div class="right">right</div>
</div>
<style>
div {
height: 100px;
}
.left {
float: left;
width: 100px;
background-color: red;
}
.center {
float: left;
width: calc(100% - 200px);
background-color: blue;
}
.right {
float: right;
width: 100px;
background-color: red;
}
</style>
4. location
<div class="container">
<div class="left">left</div>
<div class="center">center</div>
<div class="right">right</div>
</div>
<style>
div {
height: 100px;
}
.container {
position: relative;
}
.left {
position: absolute;
left: 0;
width: 100px;
background-color: red;
}
.center {
position: absolute;
left: 100px;
width: calc(100% - 200px);
background-color: blue;
}
.right {
position: absolute;
right: 0;
width: 100px;
background-color: red;
}
</style>
5. Table layout
<div class="container">
<div class="left">left</div>
<div class="center">center</div>
<div class="right">right</div>
</div>
<style>
div{
height: 100px;
}
.container {
display: table;
width: 100%;
}
.container>div {
display: table-cell;
}
.center{
background-color: blue;
}
.left,.right{
width: 100px;
background-color: red;
}
</style>
6. Grid layout
<div class="container">
<div class="left">left</div>
<div class="center">center</div>
<div class="right">right</div>
</div>
<style>
div{
height: 100px;
}
.container {
display: grid;
width: 100%;
grid-template-columns: 100px auto 100px;
}
.left,.right{
background-color: red;
}
.center{
background-color: blue;
}
</style>
7. The holy grail layout
<div class="header"> Head </div>
<div class="container clearfix">
<div class="center"> The primary area ( Priority load )</div>
<div class="left"> Left region </div>
<div class="right"> Right area </div>
</div>
<div class="footer"> Bottom </div>
<style>
.clearfix::after{
content: "";
display: block;
clear: both;
}
div{
height: 100px;
}
.header,.footer{
background-color: yellow;
}
.container{
padding: 0 100px;
}
.center,.left,.right{
float: left;
}
.center{
width: 100%;
background-color: red;
}
.left{
position: relative;
left: -100px;
margin-left: -100%;
width: 100px;
background-color: blue;
}
.right{
position: relative;
right: -100px;
margin-left: -100px;
width: 100px;
background-color: green;
}
</style>
8. Double wing layout
<div class="header"> Head </div>
<div class="container clearfix">
<div class="wrapper">
<div class="center"> The primary area ( Priority load )</div>
</div>
<div class="left"> Left region </div>
<div class="right"> Right area </div>
</div>
<div class="footer"> Bottom </div>
<style>
.clearfix::after {
content: "";
display: block;
clear: both;
}
div {
height: 100px;
}
.header,
.footer {
background-color: yellow;
}
.wrapper{
width: 100%;
float: left;
}
.center {
margin: 0 100px;
background-color: red;
}
.left {
width: 100px;
float: left;
margin-left: -100%;
background-color: blue;
}
.right {
width: 100px;
float: left;
margin-left: -100px;
background-color: green;
}
</style>
Two . Fixed width in the middle and adaptive on both sides
1.flex Layout
<div class="container">
<div class="left"></div>
<div class="center"></div>
<div class="right"></div>
</div>
<style>
div{
height: 100px;
}
.container{
display: flex;
}
.left,right{
flex: 1;
background-color: red;
}
.center{
width: 1250px;
height: 500px;
background-color: yellow;
}
</style>
2. Floating layout
<div class="container">
<div class="left">left</div>
<div class="center">center</div>
<div class="right">right</div>
</div>
<style>
div{
height:100px
}
.center{
float: left;
width: 1250px;
background-color: blue;
}
.left,.right{
float: left;
width: calc(50% - 625px);
background-color: red;
}
</style>
3.margin negative
<div class="container">
<div class="left"></div>
<div class="center"></div>
<div class="right"></div>
</div>
<style>
div{
height: 100px;
}
.center {
width: 1000px;
float: left;
background-color: yellow;
}
.left {
float: left;
width: 50%;
margin-left: -500px;
background-color: red;
}
.right {
float: right;
width: 50%;
margin-right: -500px;
background-color: blue;
}
</style>
4.display:-webkit-box;
<div class="container ">
<div class="left">left</div>
<div class="center">center</div>
<div class="right">right</div>
</div>
<style>
div{
height:100px
}
.container{
display: -webkit-box;
}
.left,.right{
-webkit-box-flex: 1;
background-color: blue;
}
.center{
width: 1250px;
background-color: red;
}
</style>
版权声明
本文为[nknmn_]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220617543505.html
边栏推荐
- The fourth operation
- 超好用的Excel异步导出功能
- 关于idea调试模式下启动特别慢的优化
- Téléchargement en vrac de fichiers - téléchargement après compression
- How to achieve centralized management, flexible and efficient CI / CD online seminar highlights sharing
- Unity Basics
- A hundred dollars for a hundred chickens
- Oracle query foreign keys contain comma separated data
- QT learning summary
- The principle and solution of not allowing pasting in an English Network
猜你喜欢
Chapter 9 of C language programming (fifth edition of Tan Haoqiang) analysis and answer of exercises for users to establish their own data types
Super easy to use asynchronous export function of Excel
Supersocket is Used in net5 - command
PYMOL-note
A comprehensive understanding of static code analysis
Chapter 8 of C language programming (fifth edition of Tan Haoqiang) is good at using pointer exercises to analyze and answer
TCP three handshakes and four waves
Supersocket is Use in net5 - concept
Knowledge of software testing~
New ORM framework -- Introduction to beetlsql
随机推荐
2022 团体程序设计天梯赛 模拟赛 L2-3 浪漫侧影 (25 分)
Supersocket is Use in net5 - concept
Talent Plan 学习营初体验:交流+坚持 开源协作课程学习的不二路径
Chapter 8 of C language programming (fifth edition of Tan Haoqiang) is good at using pointer exercises to analyze and answer
JS recursive tree structure calculates the number of leaf nodes of each node and outputs it
Chapter 9 of C language programming (fifth edition of Tan Haoqiang) analysis and answer of exercises for users to establish their own data types
socket編程 send()與 recv()函數詳解
Code forces round # 784 (DIV. 4) solution (First AK CF (XD)
Problem a: face recognition
MySQL之explain关键字详解
月薪10k-20k都无法回答的事务问题,你会吗?
Do you really understand hashcode and equals???
2022 团体程序设计天梯赛 模拟赛 L2-4 哲哲打游戏 (25 分)
MySQL索引详解【B+Tree索引、哈希索引、全文索引、覆盖索引】
移植tslib时ts_setup: No such file or directory、ts_open: No such file or director
Development record of primary sensitive word detection
Super easy to use [general excel import function]
C interface
Visual programming - drawing assignment
MySQL installation pit