Flexbox scaling layout box-HappyForEverIsaDream
Flexbox)It is a new layout mode in CSS3, designed for more complex web page requirements in modern networks.
FlexboxScaling containerAndScaling Project. You can set the display attribute of an element to flex or inline-flex to obtain a scaling container.
Setflex
The container is rendered as a block-level element and setinline-flex
Is rendered as a line element.
For example, set the element named flex-container to a scaling container.
. Flex-container {
Display:-webkit-flex;
Display: flex;
}
Each sub-element in the scaling container is a scaling project. Scaling projects can be any number. All elements outside the scaling container and within the scaling project are not affected.
To put it simply, Flexbox defines how scaling projects in a scaling container are laid out.
Flex Lines
The scaling project followsScaling rowLocate. Generally, each scaling container has only one scaling row. Default scaling row from left to right
Example:
12
Flex item 1
3Flex item 2
45 6 style: 7 8. flex-container {9 display:-webkit-flex; 10 display: flex; 11 width: 300px; 12 height: 240px; 13 background-color: Silver; 14} 15 16. flex-item {17 background-color: DeepSkyBlue; 18 width: 100px; 19 height: 100px; 20 margin: 5px; 21}
View Code
:
Add
flex item 3
Flex item 4
The width of a scaling project exceeds the width of the scaling container. The width of the scaling container does not change, and the width of the scaling project is reduced.
12
Flex item 1
3Flex item 2
45 6 7 CSS style 8. flex-container {9 direction: rtl; 10 display:-webkit-flex; 11 display: flex; 12 width: 300px; 13 height: 240px; 14 background-color: Silver; 15 16} 17 18. flex-item {19 background-color: DeepSkyBlue; 20 width: 100px; 21 height: 100px; 22 margin: 5px; 23}
View Code
Effect:
The scaling row is from right to left, and the text is also from right to left.
To describe the abstract writing mode, Flexbox usesSpindleAndSide axis. The scaling row follows the spindle. The side axis is perpendicular to the main axis.
Flex-direction scaling stream direction
Default Value: row
Again, the default value is from left to right, from top to bottom. Other values are as follows:
- Row-reverse: the spindle start point and the spindle end point are exchanged. If the writing mode is from left to right, the scaling project is displayed from left to right.
- Column: exchange between the spindle and the side axle. If the writing system is vertical, the scaling project is also vertical.
- Column-reverse: Same as column, but in the opposite direction.
Justify-content spindle alignment
Used to adjust the position of the scaling project on the spindle. Possible values:
- Flex-start (default)
- Flex-end
- Center
- Space-
- Space-around
Align-items side axis alignment
Adjust the Positioning Method of the scaling project on the side axis. Possible values include:
- Flex-start (default)
- Flex-end
- Center
- Baseline
- Stretch
Flex-wrap scaling line feed
Create multiple scaling rows for the scaling container. This property accepts the following values:
- Nowrap (default)
- Wrap
- Wrap-reverse
Align-content stack scaling row
It is aligned with the scaling row and it accepts the following values:
- Stretch (default)
- Flex-start
- Flex-end
- Center
- Space-
- Space-around
Flex-flow scaling direction and line feed are
flex-direction
And
flex-wrap
.