-
Notifications
You must be signed in to change notification settings - Fork 1
/
css-layout2.css
114 lines (97 loc) · 1.56 KB
/
css-layout2.css
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*不同方式实现CSS方式实现左右侧宽度固定,中间自适应布局*/
/*
<div class="container">
<div class="left"></div>
<div class="middle"></div>
<div class="right"></div>
</div>
*/
/*1.flex*/
.container {
display: flex;
}
.left,.right{
width: 200px;
height:800px;
border:1px solid red
}
.middle{
height:800px;
flex:1;
border:1px solid blue
}
/*2.grid*/
.container {
display: grid;
grid-template-columns: 200px auto 200px;
}
.left, .right{
height:800px;
border:1px solid red
}
.middle{
height:800px;
border:1px solid blue
}
/*3.浮动*/
/*纯float实现的三栏布局需要将中间的内容放在HTML结构的最后,否则右侧会沉在中间内容的下侧*/
.container {
overflow: hidden;
}
.left{
float: left;
width:200px;
height:800px;
border:1px solid red
}
.right{
float: right;
width:200px;
height:800px;
border:1px solid red
}
.middle{
margin: 0 200px;
height:800px;
border: 1px solid blue;
}
/*4.table*/
.container {
display: table;
width: 100%;
}
.left, .right {
display: table-cell;
width: 200px;
height: 800px;
border: 1px solid red;
}
.middle {
display: table-cell;
height: 800px;
border: 1px solid blue;
}
/*5.absolute*/
.container {
box-sizing:border-box;
position: relative;
}
.left {
position: absolute;
width: 200px;
height: 800px;
border: 1px solid red;
}
.right {
position: absolute;
right:0;
top:0;
width: 200px;
height: 800px;
border: 1px solid red;
}
.middle {
margin: 0 200px;
height: 800px;
border: 1px solid blue;
}