当前位置:网站首页>Flex flexible layout for mobile terminal page production
Flex flexible layout for mobile terminal page production
2022-06-25 05:01:00 【Dai Sensen】
Preface
Flex yes Flexible Box Abbreviation , Meaning for ” Elastic layout ”, To provide maximum flexibility for box models .Traditional solutions for layout , Based on the box model , rely on display attribute + position attribute + float attribute . It is very inconvenient for those special layouts , such as , Vertical centering is not easy to achieve .
2009 year ,W3C Put forward a new scheme —-Flex Layout , It's easy 、 complete 、 Responsive implementation of various page layouts . at present , It's supported by all browsers , It means , Now you can use this function safely .
principle
By adding... To the parent box flex attribute , To control the position and arrangement of sub boxes
use flex Elements of layout , be called flex Containers , Container for short . All of his child elements automatically become container members , be called flex project , Short for project
<style> div {
display: flex; width: 80%; height: 300px; background-color: pink; justify-content: space-around; } div span {
width: 150px; height: 100px; background-color: rgb(212, 192, 255); margin-right: 5px; flex: 1; } </style>
<body>
<div>
<span>1</span>
<span>2</span>
<span>3</span>
</div>
</body>
In the above case code , The parent box added flex, here div It's called a container , And his sub box span For projects .
Common properties of parent box
One justify,align and flex Two times two
It means that there are five important parent box attributes
One is justify start ,justify-content Set the arrangement of sub elements on the spindle
Two align start ,algin-item Set the arrangement of child elements on the side axis ( A single );align-content Set the arrangement of the child elements on the side axis ( Multiple lines )
Two flex start ,flex-wrap Set whether the child element should wrap ,flex-direction: Set the direction of the spindle
justify-content
justify-content Set the arrangement of sub elements on the spindle , However, when using this attribute, you must determine which spindle is
Common attribute values

Case study
<style> div {
/* Add... To your father flex */ display: flex; width: 800px; height: 300px; background-color: pink; /* The default spindle is x Axis row ,y The axis is the side axis , Elements are arranged along the main axis */ flex-direction: row; /* justify-content: Set the arrangement of sub elements on the spindle ; */ justify-content: space-between; } div span {
width: 150px; height: 100px; background-color: rgb(212, 192, 255); } </style>
<body>
<div>
<span>1</span>
<span>2</span>
<span>3</span>
</div>
</body>

flex-wrap
flex-wrap Set whether the child element should wrap , In general , The projects are all in one line .flex-wrap The default attribute definition is no line break , If you can't put it down , Will shrink the width of the child element
Common properties

flex-direction
flex-direction Property determines the direction of the spindle ( That is, the sorting direction of the items ), The main shaft and the side shaft change , Just look flex-direction Set who is the spindle , The rest is the side shaft , The child elements are arranged along the main axis
Common properties

align-content
align-content Set the arrangement of the child elements on the side axis ( Multiple lines ), There is no effect in a single line
Common properties

algin-item
algin-item Set the arrangement of child elements on the side axis ( A single )
Common properties

Common properties of sub boxes
flex
Number of copies of sub items
align-self
The way the items are arranged on their own side
<style> div {
display: flex; width: 80%; height: 300px; background-color: pink; align-items: flex-end; } div span {
width: 150px; height: 100px; background-color: purple; margin-right: 5px; } div span:nth-child(2) {
order: -1; } div span:nth-child(3) {
align-self: start; } </style>
</head>
<body>
<div>
<span>1</span>
<span>2</span>
<span>3</span>
</div>
order
Property defines the order in which children are arranged ( The order before and after )
<style> div {
display: flex; width: 80%; height: 300px; background-color: pink; align-items: flex-end; } div span {
width: 150px; height: 100px; background-color: purple; margin-right: 5px; } div span:nth-child(2) {
order: -1; } div span:nth-child(3) {
align-self: start; } </style>
</head>
<body>
<div>
<span>1</span>
<span>2</span>
<span>3</span>
</div>
边栏推荐
- Virtual honeypot Honeyd installation and deployment
- 初识 Flutter 的绘图组件 — CustomPaint
- Matlab notes
- [Flink] problems and solutions of the continuous growth of checkpoint size in rocksdb incremental mode
- cannot import name ‘escape’ from ‘jinja2’【成功解决】
- Web3 DAPP user experience best practices
- Get to know the drawing component of flutter - custompaint
- What is Ethernet and how to connect the computer
- Chapter IX app project test (2) test tools
- Codeforces Round #802 (Div. 2) C D
猜你喜欢

多睡觉,能减肥,芝加哥大学最新研究:每天多睡1小时,等于少吃一根炸鸡腿...

CSRF (Cross Site Request Forgery) &ssrf (server request forgery) (IV)

固態硬盤開盤數據恢複的方法

Leader: who can use redis expired monitoring to close orders and get out of here!

The SQL response is slow. What are your troubleshooting ideas?

IronOCR 2022.1 Crack

以太网是什么要怎么连接电脑

How do the defi protocols perform under this round of stress test?

CTFHub-rce

Chapter IX app project test (2) test tools
随机推荐
Teach you to write non maintainable PHP code step by step
XML (VIII)
Creation and use of MySQL index
Wechat applet new version prompt update
Calculate student grade (virtual function and polymorphism)
Difference between asemi high power FET and triode
基于SSH实现的学生成绩管理系统
API interface management setup -eolinker4.0
OOP stack class template (template +ds)
JDBC (IV)
OpenSea PHP开发包
How to install the blue lake plug-in to support Photoshop CC 2017
[relax's law of life lying on the square] those poisonous chicken soup that seem to be too light and too heavy, but think carefully and fear
Kotlin Compose 完善toDo项目 Surface 渲染背景 与阴影
Swift rapid development
ORA-00800: soft external error
Sleep more, you can lose weight. According to the latest research from the University of Chicago, sleeping more than 1 hour a day is equivalent to eating less than one fried chicken leg
Penetration information collection steps (simplified version)
TeeChart Pro ActiveX 2022.1
Mobile number regular expression input box loses focus verification