-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy path008.Flex布局的使用.html
214 lines (174 loc) · 5.1 KB
/
008.Flex布局的使用.html
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./assets/global.css">
<style>
p {
margin-block-start: 0em;
padding-top: 1em;
}
div[class^='box'] {
width: 100px;
height: 100px;
font-size: 25px;
color: #fff;
text-align: center;
line-height: 100px;
}
.box1 {
background-color: #f06;
}
.box2 {
background-color: #06f;
}
.box3 {
background-color: #0f6;
}
.default,
.row-reverse,
.column,
.column-reverse,
.default2 {
display: flex;
border: 1px solid gold;
}
.row-reverse {
flex-direction: row-reverse;
}
.column {
flex-direction: column;
}
.column-reverse {
flex-direction: column-reverse;
}
.default.flex-split1 .box1,
.default.flex-split2 .box1,
.default.flex-split2 .box2,
.default.flex-split3 .box1 {
flex: 1;
}
.default.flex-split3 .box2 {
flex: 2;
}
.default.space-between {
justify-content: space-between;
}
.default.space-around {
justify-content: space-around;
}
.default.center {
justify-content: center;
}
.default.flex-end {
justify-content: flex-end;
}
.default2 {
height: 200px;
}
.default2.flex-start {
align-items: flex-start;
}
.default2.flex-end {
align-items: flex-end;
}
.default2.center {
align-items: center;
}
</style>
</head>
<body>
<p>row(默认)</p>
<div class="default">
<div class="box1">1</div>
<div class="box2">2</div>
<div class="box3">3</div>
</div>
<p>row-reverse</p>
<div class="row-reverse">
<div class="box1">1</div>
<div class="box2">2</div>
<div class="box3">3</div>
</div>
<p>column</p>
<div class="column">
<div class="box1">1</div>
<div class="box2">2</div>
<div class="box3">3</div>
</div>
<p>column-reverse</p>
<div class="column-reverse">
<div class="box1">1</div>
<div class="box2">2</div>
<div class="box3">3</div>
</div>
<p>flex<br />当其他元素都定义好长度时flex用于分割剩余空间的比例<br />定义box1样式flex:1</p>
<div class="default flex-split1">
<div class="box1">1</div>
<div class="box2">2</div>
<div class="box3">3</div>
</div>
<p>flex<br />当其他元素都定义好长度时flex用于分割剩余空间的比例<br />定义box1,box2样式flex:1 </p>
<div class="default flex-split2">
<div class="box1">1</div>
<div class="box2">2</div>
<div class="box3">3</div>
</div>
<p>flex<br />当其他元素都定义好长度时flex用于分割剩余空间的比例<br />定义box1样式flex:1,定义box2样式flex:2 </p>
<div class="default flex-split3">
<div class="box1">1</div>
<div class="box2">2</div>
<div class="box3">3</div>
</div>
<p>justify-content:space-between<br />左右对齐</p>
<div class="default space-between">
<div class="box1">1</div>
<div class="box2">2</div>
<div class="box3">3</div>
</div>
<p>justify-content: space-around<br />两侧的间隔相等</p>
<div class="default space-around">
<div class="box1">1</div>
<div class="box2">2</div>
<div class="box3">3</div>
</div>
<p>justify-content: center<br />居中</p>
<div class="default center">
<div class="box1">1</div>
<div class="box2">2</div>
<div class="box3">3</div>
</div>
<p>justify-content: flex-end<br />集中在末端</p>
<div class="default flex-end">
<div class="box1">1</div>
<div class="box2">2</div>
<div class="box3">3</div>
</div>
<p>justify-content: flex-start<br />集中在前端</p>
<div class="default flex-start">
<div class="box1">1</div>
<div class="box2">2</div>
<div class="box3">3</div>
</div>
<p>align-items: center<br />垂直居中</p>
<div class="default2 center">
<div class="box1">1</div>
<div class="box2">2</div>
<div class="box3">3</div>
</div>
<p>align-items: flex-start<br />集中在顶端</p>
<div class="default2 flex-start">
<div class="box1">1</div>
<div class="box2">2</div>
<div class="box3">3</div>
</div>
<p>align-items: flex-end<br />集中在底端</p>
<div class="default2 flex-end">
<div class="box1">1</div>
<div class="box2">2</div>
<div class="box3">3</div>
</div>
</body>
</html>