两列布局

左侧固定,右侧自适应

float + margin

1
2
3
4
5
6
7
8
.aside {
float: left;
width: 120px;
}

.main {
margin-left: 120px;
}

padding + float + margin

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
.container {
padding-left: 120px;
}

.aside,
.main {
float: left;
}

.aside {
width: 120px;
margin-left: -120px;
}

.main {
width: 100%;
}

Flex

1
2
3
4
5
6
7
8
9
10
11
.container {
display: flex;
}

.aside {
width: 200px;
}

.main {
flex: 1;
}

display: table;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
.container {
display: table;
width: 100%;
}

.aside,
.main {
display: table-cell;
table-layout: fixed;
}

.aside {
width: 120px;
}

float + BFC(overflow: hidden)

1
2
3
4
5
6
7
8
.aside {
float: left;
width: 120px;
}

.main {
overflow: hidden;
}

position: absolute

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
.container {
position: relative;
}

.aside {
position: absolute;
left: 0;
width: 120px;
}

.main {
position: absolute;
left: 120px;
right: 0;
}

右侧固定,左侧自适应

padding-right + margin-right(负)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
.container {
padding-right: 120px;
}

.main {
float: left;
width: 100%;
}

.aside {
float: right;
width: 120px;
margin-right: -120px;
}

flex

1
2
3
4
5
6
7
8
9
10
11
.container {
display: flex;
}

.main {
flex: 1;
}

.aside {
width: 120px;
}