当前位置:网站首页>Flexible layout (I)
Flexible layout (I)
2022-07-07 07:14:00 【Luqi zz】
Catalog
1 Declare block level elastic box display:flex
2 Declare inline elastic box display:inline-flex
Two 、flex-direction: Used to control the arrangement direction of box elements .
row-reverse Arrange elements from right to left
column-reverse Arrange elements vertically from bottom to top
Vertical element wrap column 、wrap
Vertical elements wrap in reverse column wrap-reverse
One 、 Declaration definition
Container box contains container elements , Use display:flex
or display:inline-flex
Declared as an elastic box .
1 Statement Block level Elastic box display:flex
<style>
* {
padding: 0;
margin: 0;
}
article {
height: 150px;
margin-left: 100px;
margin-top: 100px;
outline: solid 5px silver;
display: flex;
padding: 20px;
}
article div {
outline: solid 5px orange;
text-align: center;
font-size: 28px;
line-height: 5em;
width: 300px;
}
</style>
<!-- Declare block level elastic box -->
<body>
<article>
<div>1</div>
<div>2</div>
<div>3</div>
</article>
</body>
2 Declare inline elastic box display:inline-flex
<style>
...
article {
...
display: inline-flex;
...
}
...
</style>
Two 、flex-direction: Used to control the arrangement direction of box elements .
Use in display:flex
In the parent container of , Change the direction of the horizontal axis :
value | describe |
---|---|
row | Arrange elements horizontally from left to right ( The default value is ) |
row-reverse | Arrange elements from right to left |
column | Arrange elements vertically from top to bottom |
column-reverse | Arrange elements vertically from bottom to top |
row-reverse Arrange elements from right to left
<style>
* {
padding: 0;
margin: 0;
}
body {
margin: 100px;
font-size: 14px;
color: #555;
}
article {
width: 500px;
border: solid 5px silver;
display: flex;
box-sizing: border-box;
padding: 10px;
/* row-reverse Arrange elements from right to left */
flex-direction: row-reverse;
}
article * {
border: solid 5px orange;
padding: 10px;
margin: 10px;
}
</style>
...
<body>
<article>
<h4>1</h4>
<span>2</span>
<p>3</p>
</article>
</body>
column-reverse Arrange elements vertically from bottom to top
<style>
* {
padding: 0;
margin: 0;
}
body {
margin: 100px;
font-size: 14px;
color: #555;
}
article {
width: 500px;
border: solid 5px silver;
display: flex;
box-sizing: border-box;
padding: 10px;
/* column-reverse Arrange elements vertically from bottom to top */
flex-direction: column-reverse;
}
article * {
border: solid 5px orange;
padding: 10px;
margin: 10px;
}
</style>
...
<body>
<article>
<h4>1</h4>
<span>2</span>
<p>3</p>
</article>
</body>
3、 ... and 、flex-wrap
Regulations flex The container is one or more lines , At the same time, the direction of the horizontal axis determines the direction of the new row stack .
Options | explain |
---|---|
nowrap | Elements do not split rows or columns ( The default value is ) |
wrap | Container elements split rows or columns when necessary . |
wrap-reverse | Container elements split rows or columns when necessary , But in reverse order |
Line element wrap row 、wrap
<style>
* {
padding: 0;
margin: 0;
outline: solid 1px silver;
padding: 10px;
margin: 10px;
}
head {
display: block;
}
body {
font-size: 14px;
color: #555;
}
article {
width: 500px;
height: 250px;
border: solid 5px silver;
box-sizing: border-box;
padding: 10px;
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
article div {
border: solid 5px orange;
padding: 30px 80px;
margin: 10px;
text-align: center;
font-size: 28px;
}
</style>
...
<article>
<div>1</div>
<div>2</div>
<div>3</div>
</article>
Horizontal arrangement reverse line feed row 、wrap-reverse
flex-direction: row;
flex-wrap: wrap-reverse;
Vertical element wrap column 、wrap
flex-direction: column;
flex-wrap: wrap;
Vertical elements wrap in reverse column wrap-reverse
flex-direction: column;
flex-wrap: wrap-reverse;
Four 、flex-flow
yes flex-direction
And flex-wrap
The combination abbreviation mode of .
The following is arranged from right to left , Line breaking up branches .
flex-flow: row-reverse wrap-reverse;
边栏推荐
猜你喜欢
Sword finger offer high quality code
Bus message bus
From zero to one, I will teach you to build the "clip search by text" search service (2): 5 minutes to realize the prototype
main函数在import语句中的特殊行为
.net core 访问不常见的静态文件类型(MIME 类型)
Esxi attaching mobile (Mechanical) hard disk detailed tutorial
FPGA course: application scenario of jesd204b (dry goods sharing)
弹性布局(一)
Can 7-day zero foundation prove HCIA? Huawei certification system learning path sharing
Leetcode t1165: log analysis
随机推荐
At the age of 20, I got the ByteDance offer on four sides, and I still can't believe it
Master-slave replication principle of MySQL
Big coffee gathering | nextarch foundation cloud development meetup is coming
PostgreSQL source code (59) analysis of transaction ID allocation and overflow judgment methods
Composition API premise
FullGC问题分析及解决办法总结
LC interview question 02.07 Linked list intersection & lc142 Circular linked list II
Unity3d learning notes
freeswitch拨打分机号源代码跟踪
Basic process of network transmission using tcp/ip four layer model
"Xiaodeng in operation and maintenance" meets the compliance requirements of gdpr
Lm11 reconstruction of K-line and construction of timing trading strategy
main函数在import语句中的特殊行为
from . onnxruntime_ pybind11_ State Import * noqa ddddocr operation error
After the promotion, sales volume and flow are both. Is it really easy to relax?
Initial experience of addresssanitizer Technology
工具类:对象转map 驼峰转下划线 下划线转驼峰
How does an enterprise manage data? Share the experience summary of four aspects of data governance
oracle如何备份索引
readonly 只读