1.两侧定宽,中栏自适应
2. 一列不定宽,一列自适应
3. 多列等分布局
4. 九宫格布局
实现方式:
使用float+margin实现
使用flex实现
使用table实现
使用float+margin实现
.parent {
width: 500px;
height: 100px;
}
.left {
width: 100px;
height: 100px;
background-color: #2AC845;
float: left;
margin-right: 30px;
}
.center {
width: 100%;
height: 100px;
float: left;
margin-right: -150px;
background-color:blanchedalmond;
}
.right {
width: 100px;
height: 100px;
background-color:pink;
float: right;
margin-right: -250px;
}
使用flex实现
代码
.parent {
width: 500px;
height: 100px;
display: flex;
}
.left {
width: 100px;
height: 100px;
background-color: #2AC845;
}
.center {
flex: 1;
height: 100px;
background-color: #007AFF
}
.right {
width: 100px;
height: 100px;
background-color:pink;
}
利用table实现布局
.parent {
width: 100%;
height: 100px;
display: table;
table-layout: fixed;
}
.left {
width: 100px;
height: 100px;
background-color: #2AC845;
display: table-cell;
}
.center {
height: 100px;
background-color: #007AFF;
display: table-cell
}
.right {
width: 100px;
height: 100px;
background-color:pink;
display: table-cell
}
一列不定宽,一列自适应
1.利用float+overflow实现</