【英文】Flex学习笔记
Preface
Flex Layout Study Notes
Parent Element Properties
- When the box is set to flex layout, the float, clear, and vertical-align properties of the child elements will be invalid.
- If the main axis is horizontal, the cross axis is vertical; if the main axis is vertical, the cross axis is horizontal.
display: flex;
: Use flex layout.flex-direction
: set the direction of the main axis
row
: The default value, from left to rightrow-reverse
: From right to leftcolumn
: From top to bottomcolumn-reverse
: From bottom to top
flex-wrap
: set whether the child elements wrap
nowrap
: The default value, no automatic wrapping. In this case, if there are too many child elements, it will force the size of the child elements to change.wrap
: Automatically wrap. In this case, whether the child elements are too many or not, it will not change the size of the child elements and will automatically wrap the elements that cannot fit.
flex-flow: flex-direction flex-wrap
: Set the direction of the main axis and whether to wrap at the same time.justify-content
: Set the arrangement of the child elements on the main axis.
flex-start
: The default value, from start to end.flex-end
: From end to start.center
: Centeredspace-around
: Equally distribute the remaining space, with gaps on both sides.space-between
: Equally distribute the remaining space, without gaps on both sides.
align-items
: For single-line child elements, set the arrangement of the child elements on the cross axis.
flex-start
: The default value, from start to end.flex-end
: From end to start.center
: Center alignment.stertch
: Stretch alignment (child boxes cannot specify height).
align-content
: For multi-line child elements, set the arrangement of the child elements on the cross axis.
flex-start
: The default value, from start to end.flex-end
: From end to start.center
: Align the child elements as a whole in the center.space-around
: The child elements are close to both sides of the cross axis.space-between
: Each row of child elements is equally divided on the cross axis, and then aligned as a whole in the center.
1 | <html> |
Child Element Properties
Allocate Remaining Space to Child Elements
flex <num>
: Specify weight proportion.
1 | <html> |
Control the arrangement of the current child element on the cross axis
- Override the
align-items
property of the child element by using thealign-self
property.
align-self
: For single-line child elements, set the arrangement of the child elements on the cross axis.
auto
: Follow thealign-self
property of the parent element. If there is no parent element, align withstertch
.flex-start
: From start to end.flex-end
: From end to start.center
: Center alignment.stertch
: Stretch alignment (child boxes cannot specify height).
1 | <html> |
Specify the arrangement order of child items
order <num>
: Specify the arrangement order of child items. The smaller the number, the closer to the front, it can be 0, positive number or negative number.
0
: Default value.
1 | <html> |