forked from wteam-xq/testDemo
-
Notifications
You must be signed in to change notification settings - Fork 1
/
cssFlexBox.html
175 lines (157 loc) · 4.88 KB
/
cssFlexBox.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
<!-- 代码来自教程:http://www.w3cplus.com/blog/666.html -->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>
伸缩布局盒
</title>
<style>
/* 在线查CSS API: http://css.doyoe.com/ */
body { /*direction: rtl;*/ }
.demo_source{
margin-left:10px;
}
.demo-container{ display: -webkt-flex; display: flex; -webkit-align-content: center; align-content: center; -webkit-flex-wrap: wrap; flex-wrap: wrap; }
.demo-item{ margin: 10px; }
.flex-container {
display: -webkit-flex;
display: flex;
width: 300px;
height: 240px;
background-color: Silver;
/*主轴方向*/
/*-webkit-flex-direction: column;
flex-direction: column;*/
/*主轴对齐*/
/*-webkit-justify-content: center;
justify-content: center;*/
/*侧轴对齐*/
/*-webkit-align-items: center;
align-items: center;*/
/*flex-flow flex-direction 和 flex-wrap 的缩写*/
/*伸缩行换行*/
/*-webkit-flex-wrap: wrap;
flex-wrap: wrap;*/
/*align-content 堆栈伸缩行 对齐伸缩行*/
/*-webkit-align-content: center;
align-content: center;*/
}
.flex-container1 {
display: -webkit-flex;
display: flex;
width: 300px;
height: 240px;
background-color: Silver;
/*主轴对齐*/
-webkit-justify-content: center;
justify-content: center;
}
.first {
-webkit-order: -1;
order: -1;
}
.flex-item {
background-color: DeepSkyBlue;
width: 50px;
height: 100px;
margin: 5px;
}
.flex-item:first-child {
/*margin-right: auto;*/
}
.flex-item1{
background-color: DeepSkyBlue;
width: 100px;
height: 100px;
margin: auto;
}
.item1 {
-webkit-align-self: flex-start;
align-self: flex-start;
}
.item2 {
-webkit-align-self: flex-end;
align-self: flex-end;
}
.item3 {
-webkit-align-self: center;
align-self: center;
}
.item4 {
-webkit-align-self: baseline;
align-self: baseline;
}
.item5 {
-webkit-align-self: baseline;
align-self: baseline;
padding: 2em 0;
}
.item6 {
-webkit-align-self: stretch;
align-self: stretch;
}
.item7 {
-webkit-flex: 3;
flex: 3;
}
.item8 {
-webkit-flex: 1;
flex: 1;
}
.item9 {
-webkit-flex: 1;
flex: 1;
}
</style>
<link rel="icon" href="favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
</head>
<body>
<div class="demo_source"><a href="http://www.w3cplus.com/blog/666.html" target="_blank">本demo 对应教程</a></div>
<div class="demo-container">
<div class="demo-item">
<h3> 设置优先级 order</h3>
<div class="flex-container">
<div class="flex-item">flex item 1</div>
<div class="flex-item first">flex item 2(flex-order:-1)</div>
<div class="flex-item">flex item 3</div>
</div>
</div>
<div class="demo-item">
<h3> margin:auto 真居中对齐</h3>
<div class="flex-container">
<div class="flex-item1">I'm centered!</div>
</div>
</div>
<div class="demo-item">
<h3> align-itme align-self 侧轴对齐</h3>
<div class="flex-container">
<div class="flex-item item1">flex-start</div>
<div class="flex-item item2">flex-end</div>
<div class="flex-item item3">center</div>
<div class="flex-item item4">base</div>
<div class="flex-item item5">line</div>
<div class="flex-item item6">stretch</div>
</div>
</div>
<div class="demo-item">
<h3> 伸缩性flex[num]3 1 1</h3>
<div class="flex-container">
<div class="flex-item item7">flex2</div>
<div class="flex-item item8">flex1</div>
<div class="flex-item item9">flex1</div>
</div>
</div>
<div class="demo-item">
<h3> 主轴对齐 justify-content</h3>
<div class="flex-container1">
<div class="flex-item1">flex2</div>
<div class="flex-item1">flex1</div>
</div>
</div>
</div>
<script>
</script>
</body>
</html>