当前位置:网站首页>弹性布局(一)
弹性布局(一)
2022-07-07 03:22:00 【鹿蹊zz】
目录
2 声明内联级弹性盒子 display:inline-flex
二、flex-direction:用于控制盒子元素排列的方向。
一、声明定义
容器盒子里面包含着容器元素,使用display:flex 或 display:inline-flex 声明为弹性盒子。
1 声明块级弹性盒子 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>
<!-- 声明块级弹性盒子 -->
<body>
<article>
<div>1</div>
<div>2</div>
<div>3</div>
</article>
</body>2 声明内联级弹性盒子 display:inline-flex

<style>
...
article {
...
display: inline-flex;
...
}
...
</style>二、flex-direction:用于控制盒子元素排列的方向。
使用在display:flex的父容器里,改变横轴的方向:
| 值 | 描述 |
|---|---|
| row | 从左到右水平排列元素(默认值) |
| row-reverse | 从右向左排列元素 |
| column | 从上到下垂直排列元素 |
| column-reverse | 从下到上垂直排列元素 |
row-reverse 从右向左排列元素

<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 从右向左排列元素 */
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 从下到上垂直排列元素

<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 从下到上垂直排列元素 */
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>
三、flex-wrap
规定flex容器是单行或者多行,同时横轴的方向决定了新行堆叠的方向。
| 选项 | 说明 |
|---|---|
| nowrap | 元素不拆行或不拆列(默认值) |
| wrap | 容器元素在必要的时候拆行或拆列。 |
| wrap-reverse | 容器元素在必要的时候拆行或拆列,但是以相反的顺序 |
行元素换行 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>水平排列反向换行 row 、wrap-reverse

flex-direction: row;
flex-wrap: wrap-reverse;
垂直元素换行 column 、wrap

flex-direction: column;
flex-wrap: wrap;垂直元素反向换行 column wrap-reverse

flex-direction: column;
flex-wrap: wrap-reverse;四、flex-flow
是 flex-direction 与 flex-wrap 的组合简写模式。
下面是从右向左排列,换行向上拆分行。

flex-flow: row-reverse wrap-reverse;边栏推荐
- Basic introduction of JWT
- How to share the same storage among multiple kubernetes clusters
- OOM(内存溢出)造成原因及解决方案
- MySQL的主从复制原理
- Databinding exception of kotlin
- AddressSanitizer 技术初体验
- Basic process of network transmission using tcp/ip four layer model
- Four goals for the construction of intelligent safety risk management and control platform for hazardous chemical enterprises in Chemical Industry Park
- MySQL binlog related commands
- Learning records on July 4, 2022
猜你喜欢

Several index utilization of joint index ABC

联合索引ABC的几种索引利用情况

AVL树的实现

大咖云集|NextArch基金会云开发Meetup来啦

Unity3d learning notes

Big coffee gathering | nextarch foundation cloud development meetup is coming

Leetcode t1165: log analysis

Precise space-time travel flow regulation system - ultra-high precision positioning system based on UWB

mysql查看bin log 并恢复数据

. Net 5 fluentftp connection FTP failure problem: this operation is only allowed using a successfully authenticated context
随机推荐
Anr principle and Practice
This article introduces you to the characteristics, purposes and basic function examples of static routing
JDBC database connection pool usage problem
[Luogu p1971] rabbit and egg game (bipartite game)
From zero to one, I will teach you to build the "clip search by text" search service (2): 5 minutes to realize the prototype
freeswitch拨打分机号源代码跟踪
2022/07/04学习记录
Networkx drawing and common library function coordinate drawing
MySQL view bin log and recover data
Test of transform parameters of impdp
Composition API 前提
Please answer the questions about database data transfer
.net 5 FluentFTP连接FTP失败问题:This operation is only allowed using a successfully authenticated context
How to do sports training in venues?
子组件传递给父组件
Can 7-day zero foundation prove HCIA? Huawei certification system learning path sharing
Libcurl returns curlcode description
MySQL SQL的完整处理流程
Four goals for the construction of intelligent safety risk management and control platform for hazardous chemical enterprises in Chemical Industry Park
Basic process of network transmission using tcp/ip four layer model