Summary of the Flex

Summary of the Flex

Elastic box model (flex), we generally used to implement the page layout, of course flex usage is very flexible, in addition to a plurality of cassette blocks arranged horizontally, we can also use flex lines for a plurality of cassettes of the same row in the horizontal and vertical the arrangement direction of the effect, such as a plurality of line span tags, we want its horizontal alignment, can display attribute was added flex, then justify-content value of space-between, can be realized, including the horizontal direction, we want different vertical height of the box is centered, may be used align-items or align-content, center attribute value can be realized, of course, other effects if desired, may take different attributes and attribute values.

Flex Set display property (elastic box model), first conventional cassette blocks arranged as follows:

Here Insert Picture Description
After setting the Display property value flex, block elements horizontally arranged can be achieved:
Here Insert Picture Description

The properties of the container

1, flex-direction to determine the alignment direction of the sub-elements (i.e., the arrangement direction of the project)
Value 1: row default value, the horizontal direction of the spindle, the sub-elements from left to right;
Here Insert Picture Description
Value 2: row-reverse: horizontal spindle direction, starting at the right end of the vessel, in reverse order (flex-direction: row-reverse ;);
Here Insert Picture Description
value 3: column, cross shaft arrangement (flex-direction: column;)
Here Insert Picture Description
value 4: column-reverse; in the box so that cross-axis to achieve reverse order (Flex-direction: Reverse-column;)
Here Insert Picture Description
2, Flex-fit line if a predetermined wrap how newline.
When the element width is greater than the total width of the container, will involve wrap or not, the amount of container becomes default, all items are ranked in a line, flex-wrap defines how less than if the discharge line wrap. It has three possible values:
(. 1) nowrap (default): not wrap. Even if the total width of the box is greater than the width of the container does not wrap
Here Insert Picture Description
(2) wrap: wraps, the surplus will wrap without pinching (Flex-wrap: wrap;)
Here Insert Picture Description
(. 3) wrap-Reverse: line feed, not only wrap, but also in reverse order from the bottom up. (Flex-wrap: wrap-reverse ;)
Here Insert Picture Description

justify-content is defined on the spindle of the ## title aligned ways

justify-content defines the project is aligned on the spindle. It has six possible values:
(. 1) Start-Flex (default) is aligned to the start position of the spindle, which is arranged starting from the starting position of the spindle. (The justify-Content: Start-Flex;)
Here Insert Picture Description
(2) End-Flex: a position aligned to the spindle end, thus abutting the end of the main shaft, but does not affect the order of elements. (The justify-Content: End-Flex;)
Here Insert Picture Description
(. 3) Center: centered (justify-content: center;) centered on the spindle direction
Here Insert Picture Description
(4) space-between; justification, it is noted that the left and right ends of elements will space is against the left and right sides of the container, the remaining (major axis direction) equally among the remaining elements. (The justify-Content: Space-BETWEEN;)
Here Insert Picture Description
(. 5) Space-around; dispersion aligned, to be noted that elements do not abut against the left and right both ends of the left and right sides of the container (note the distinction between aligned and aligned at both ends and an average difference ), the remaining space in the container (spindle direction) evenly distributed by the element into the direction of their start and end of the spindle (note that the major axis direction is horizontal or vertical) sides (left and right from the elements and thus the container on both sides of the edge elements of the only half the distance between). (The justify-Content: Space-BETWEEN;)
Here Insert Picture Description
(. 6) Space-EVENLY; evenly, it is to allocate all remaining space on average in all directions main container; dispersion aligned and the difference is, the distance between each element and a spindle the distance between the start and the end edge of the element and the sides of the container are the same general direction. (Justify-content: space-evenly ;)
Here Insert Picture Description

align-items define how projects are aligned in the cross-axis (vertical axis)

align-items define the attribute item (Also note that if the spindle has changed direction) should be aligned on the cross shaft. It may take five values. DETAILED alignment direction intersecting the axis-related, cross-axis from top to bottom the following is assumed.
(1) flex-start: the starting point of cross-axis alignment (and default values). (Align = left-items: Flex-Start;)
Here Insert Picture Description
(2) End-Flex: end cross-axis alignment. (Align = left-items: Flex-End;)
Here Insert Picture Description
(. 3) Center; the cross direction of the central axis aligned; (align-items: center)
Here Insert Picture Description

align-content defines a plurality of axes (multi-line) alignment

(1) flex-start: the starting point of cross-axis alignment; (align = left-Content: Flex-Start;)
Here Insert Picture Description
(2) Flex-End: cross-axis swollen point alignment; (align = left-Content: Flex-End;)
Here Insert Picture Description
(. 3) center; axis intersecting a midpoint; (Content-align = left: center;)
Here Insert Picture Description
(. 4) Space-around; dispersion aligned, to be noted that the elements do not intersect both ends of the shaft against the sides of the container (note the distinction between the two ends, and alignment, and the difference between the average alignment), the remaining space in the container (the cross-axis direction) of the elements evenly to their start and end cross-axis direction (note the cross direction is a horizontal or vertical axis) of both sides (and therefore the cross shaft elements from both sides of the edge of the container half) the distance between the elements. (Content-align = left: Space-BETWEEN;)
Here Insert Picture Description
(. 5) Space-BETWEEN; justification, it is noted that both ends of the project will have cross-axis against the left and right sides of the container, (major axis direction) from the rest of the space remaining elements equally. . (Content-align = left: Space-BETWEEN;)
Here Insert Picture Description
(. 6) Space-EVENLY; evenly, is to have evenly on all containers remaining space intersecting the axial direction; and a difference between the dispersion is aligned, the distance between each item and cross-axis direction and the end of the project the distance between the sides of the container rim is large as the start. (Align-content: space-evenly ;)
Here Insert Picture Description

The project properties

1, flex-grow; the default value is 0, the sub flex container provided for the parent container divide the remaining space, we can set the value, the greater the higher the weight assigned a weight value between the respective item.
Such items originally in the container are arranged in such a manner (not support full container)
Here Insert Picture Description
prosthesis into a cassette 3 is provided a flex-grow, the box 3 will hold the remaining space filled container (flex-grow on the spindle: 1; the as shown in FIG.)
Here Insert Picture Description
2, Order attribute defines the sort items, the smaller the value, the more forward arrangement, the default value is 0, for example, we attribute value 3 to the box 1, the box 2 to the attribute value of 2, 4 of the box 3 , the box 1 is 4, so the sub-box will be the order of 1234 becomes 3241.
Here Insert Picture Description
3, flex-shrink attribute defines the reduction ratio of the items, the default value is 1, if all the items are the default attribute value 1, when there is insufficient space will be scaled down. If a project in which the property is 0, 1 other default, when the lack of space, the former does not shrink. (This property is not negative), as shown below, box 4 flex-shrink attribute value is set to 0, the default other cassette 1, when the lack of space, the box 4 is not reduced.
Here Insert Picture Description
4, flex-basis attribute defines the spindle space before allocating extra space, occupied by the project. Browser based on this property to calculate whether the spindle has enough free space. The default value of auto (the original size of the project).
5, flex property, which is a flex-grow, flex-shrink and flex-basis shorthand, default value 0 1 auto, the two values may be selected according to their values or not to need (the default), but also Note the order between them.
6, align-self attribute set to a single item, allowing a single item and other items may have different arrangements (weight is greater than align-item attribute default value auto).

Published 19 original articles · won praise 0 · Views 302

Guess you like

Origin blog.csdn.net/Joey_Tribiani/article/details/103095521