First, Flex basic properties
Elements with a Flex layout are called Flex containers, or containers for short. All of its child elements automatically become container members and are called Flex items, or items for short. The document
// block level element. Box {display: flex; } // Inline element. Box {display: inline-flex; } // Webkit-kernel browsers must be prefixed with -webkit. box{display: -webkit-flex; /* Safari */ display: flex; }Copy the code
With Flex layout, the following attributes of child elements are invalidated:
float
clear
vertical-align
The container
There are two axes by default: horizontalMain Axis
And the verticalCross axis
.
Container properties
There are six properties on the container:
flex-direction
(Main axis) :row
|row-reverse
|column
|column-reverse
flex-wrap
(newline) :nowrap
| (not a newline)wrap
(the first row at the top) |wrap-reverse
(First line below)flex-flow
(flex-direction
andflex-wrap
Short form) :row nowrap
(Default value)justify-content
(Alignment on spindle) :flex-start
|flex-end
|center
|space-between
|space-around
align-items
(How to align the cross axis) :flex-start
|flex-end
|center
|baseline
|stretch
align-content
(Alignment of multiple axes, only one axis, this property does not work) :flex-start
|flex-end
|center
|space-between
|space-around
|stretch
(The core is that the element inside the box must exceed the width of the box item (default).
3. Project attributes
There are six attributes on the project:
order
(The order of items. The smaller the value, the more advanced the order, default is 0) :<integer>
flex-grow
(Default is 0) :<number>
flex-shrink
(The scale of the project, default is 1, that is, if the space is insufficient, the project will shrink) :<number>
flex-basis
(The main axis space occupied by the project before allocating extra space) :<length> | auto
flex
(flex-grow
.flex-shrink
和flex-basis
Short for, the default value is0 1 auto
) :align-self
Allow a single item to have a different alignment than other items and be overriddenalign-items
Properties. The default value isauto
) :auto
|flex-start
|flex-end
|center
|baseline
|stretch
Refer to the article
- Flex Layout Tutorial: Syntax section
- CSS Guidebook- Flexible layout
- Flex Flex layout
- Basics: Flex- Elastic layout is so easy!!
- Flex Layout Tutorial: Sample article
- Common CSS layouts (very comprehensive)
To look at
- Take a look at the beauty of flex layout with 48 illustrations