What is Flexbox? Description of all CSS powers, basic principles, advantages and disadvantages. Layout at a glance CSS Flexbox Basics of CSS Flexbox
Flexbox is ideal for creating widely used website layouts, on a three-column basis, so-called “Holy Grail” layout, where all the columns must take up the same height, regardless of how they fit together. When it comes to output code the main one goes before navigation, and on the very page the main one goes after navigation.
Nachebto tsyogo.
Before the advent of flexboxes, such a layout could be easily achieved without any hacks or wikis. Developers often had to try things like adding additional markings, adding negative margins, and other tricks to ensure that everything would work correctly regardless of the size of the screen. Well, as the pointing method shows, everything is much simpler on Flexbox.
Axis short viklad code. In this application, we use the #main element as a flex container, and fill the header and footer with block elements. In other words, only the middle part becomes a flexbox. The axis is a fragment that can be used with a flex container.
#main (display: flex; min-height: calc (100vh - 40vh);)
Just use display: flex to create a flex container. To return the value, we also set the min-height value for the additional function calc () and set #main as 100% of the height of the view area minus height of the cap and base (20vh each). This guarantees that the layout will occupy the entire height of the screen, as there is not enough space in it. As a result, the basement will not rise at all and will not take away the empty space below it, which instead takes up less screen height.
The calculation of min-height was to be completed, forgive us, doctors, so we set box-sizing: border-box to all elements. If we didn’t collect anything, then it would be necessary to add the padding value to the sum for conversion.
After installing the flex container, we are placed to the right of the flex elements.
#main> article (flex: 1;) #main> nav, #main> aside (flex: 0 0 20vw; background: beige;) #main> nav (order: -1;)
Power flex is shorthand for power flex-grow, flex-shrink and flex-basis. In the first step we wrote only one value, so flex installs the power of flex-grow. In another example, we wrote all three values for
I would like to hear about FlexBox. The Flexbox layout module (flexible box - “flexible block”, currently W3C Candidate Recommendation) sets the task of establishing a more effective layout method, aligning and distributing a suitable place between elements in a container, especially if their size is not the same home and / or dynamic (from the word "gnuchky")
The main idea of flex-layout in a container is to change the width / height (and order) of its elements to quickly fill the space (mostly to accommodate all types of displays and screen sizes iv).The flexible container stretches the elements to fill the empty space or compresses them to prevent them from going beyond the boundaries.
Most importantly, the flexbox layout should not be placed directly on top of the basic layouts (blocks, stacked vertically, and online elements, stacked horizontally).Since the original layout is ideal for web pages, there is no flexibility to support large or foldable add-ons (especially if you go to the right to change the orientation of the screen, change the size, tightness, etc.).
Oskolki flexbox is a whole module, and not just a single unit, it combines the absence of powers.Each of them can be consolidated to the container (the Father’s element, the so-called flex-container), at the same time as other authorities will be consolidated to the child elements, or flex-elements.
Just as the basic layout is primed on the direct flows of block and online elements, the flex layout is primed on the “direct flows of the flex flow”.
Flexbox
Basically, the elements will be distributed either at the head axis (from main-start to main-end) or along the transverse axis (from cross-start to cross-end).
main-axis - the main axis of all flex elements.To be honest, it is obligatory to be horizontal, everything should be kept within the context of justify-content.
main-start | main-end - flex elements are placed in a container under the main-start position and main-end position.
main size - width or height of the flex element in the position based on the selected base value.The main value can be either the width or the height of the element.
cross axis - the whole thing is transverse, perpendicular to the head.It should be directly aligned with the direction of the head axis.
cross-start | cross-end - flex rows will be filled with elements and placed in a container as a cross-start position and a cross-end position.
cross size - the width or height of the flex element in position according to the selected size is equal to the same size.This power is avoided by the width or height of the element in the layout according to the given dimension.
power
display: flex | inline-flex;
This means a flex container (online or block layout depending on the selected value), which includes a flex context for all of its middle pads.
display: other values | flex | inline-flex;
Please respect:
CSS columns do not work with flex containerfloat, clear and vertical-align do not work with flex elements
flex-direction
Sticks to the father’s element of the flex container.
I insert the head of the entire main-axis, which means that it is the direct location for the flex elements to be placed in the container.
flex-direction: row | row-reverse | column | column-reverse
row (behind the background): from left to right for ltr, from right to left for rtl;
row-reverse: right to left for ltr, left to right for rtl;
column: same as row, downwards;
column-reverse: similar to row-reverse, from bottom to top.
flex-wrap
Sticks to the father’s element of the flex container.
This means that the container is single-row or multi-row, as well as the direction of the transverse axis, which means in which the new rows will be distributed.
flex-wrap: nowrap | wrap | wrap-reverse
nowrap (for zamovchuvannyam): single-row / left to the right for ltr, right to left for rtl;
wrap: multi-line / left to right for ltr, right to left for rtl;
wrap-reverse: multi-line / right to left for ltr, left to right for rtl.
flex-flow
Sticks to the father’s element of the flex container.
This means flex-direction and flex-wrap, which simultaneously mean the head and transverse axes.The value for wrapping is taken to be row nowrap.
flex-flow< ‘flex-direction’> || < ‘Flex-wrap’>
justify-content
Sticks to the father’s element of the flex container.
This means the alignment of the cephalic axis.It ensures an effective distribution when the elements of the row do not “stretch”, but stretch, but have already reached their maximum size.It also allows for the complete rotation of elements when going beyond the row boundaries.
justify-content: flex-start | flex-end | center | space-between | space-around
flex-start (after wrapping): elements are wrapped up to the beginning of the row;
flex-end: elements are closed until the end of the row;
center: elements align to the middle of the row;
space-between: elements are distributed evenly (the first element is at the beginning of the row, the remaining element is at the end)
space-around: elements are distributed evenly with equal distance between each other and rowing position.
justify-content
align-items
Sticks to the father’s element of the flex container.
It indicates the behavior of the wrapping process in order for the flex elements to be rotated along the transverse axis on the production row.Use this version of justify-content for the transverse axis (perpendicular to the main one).
align-items: flex-start | flex-end | center | baseline | stretch
flex-start: cross-start border for elements of cross-start position expansion;
flex-end: cross-end border for elements of cross-end positions;
center: elements are aligned along the center of the transverse axis;
baseline: elements are aligned along their base line;
stretch (for wrapping): elements are stretched, filling the container (with min-width / max-width settings).
align-items
align-content
Sticks to the father’s element of the flex container. The vertical rows of a flex container when there is clear space on the transverse axis is similar to how to work justify-content on the head axis. Note: this power does not work with single-row flexboxes.
align-content: flex-start | flex-end | center | space-between | space-around | stretch
flex-start: rows are aligned to the front of the container;
flex-end: rows are aligned to the end of the container;
center: rows are aligned in the center of the container;
space-between: the rows are distributed evenly (the first row is on the cob of the row, the remaining row is at the end)
space-around: rows are distributed evenly with equal space between each other;
stretch (for washing): the rows are stretched, creating a free space.
align-content
order
After installation, the flex elements are arranged in cob order.Prote, the power of order can control the order of their distribution in the container.
order 1
flex-grow
Coupled to the child element / flex element. This means that a flex element can “grow” if necessary.It takes on immeasurable values and is used in proportion.This means that the element can occupy a free space in the middle of the container. Since the flex-grow power of all elements is set to 1, then the skin in the middle of the container takes the same size.If you set one of the areas to a value of 2, then you will borrow twice as much space as the others.
flex-grow
flex-shrink
Coupled to the child element / flex element.
Indicates the ability of a flex element to shrink when necessary.
flex-shrink
Negative numbers are not accepted.
flex-basis
Coupled to the child element / flex element. This means the size of the material used for the element before dividing the space in the container.
flex-basis
flex
Coupled to the child element / flex element. This is shorthand for flex-grow, flex-shrink and flex-basis.The other and third parameters (flex-shrink, flex-basis) are binding.Value for cleaning - 0 1 auto.
flex: none | [< ‘Flex-grow «> <» flex-shrink’>? || < ‘Flex-basis’>]
align-self
Coupled to the child element / flex element. Allows you to re-value the ranking, assignments or align-items, for other flex elements. Return to the description of the power of align-items for a short overview of the available values.
align-self: auto | flex-start | flex-end | center | baseline | stretch
apply it
Nowadays, with a very simple butt, it is sharpened almost every day: the alignment is exactly in the center.There is nothing simpler than using flexbox.
Parent (display: flex; height: 300px;).child (width: 100px; / * Whatever the case * / height: 100px; / * Whatever the case * / margin: auto; / * Magic! * /)
This example is based on the fact that the margin under the flex-containers, tasks like auto, fills the entire space, so the given approach in this way aligns the element exactly in the center along the offending axes. Now let's look at some of the authorities.Find a set of 6 elements of a fixed size (for paint), but you can change the size of the container.We want to distribute them evenly horizontally, so that when resizing the browser window everything looks good (without @ media queries!).
Flex-container (
/ * The flex-context is now soluble * /
display: flex;
/ * Now it is important to direct the flow and what we want, so that the elements
transferred to a new row
* Remember that this is the same as:
* Flex-direction: row;
* Flex-wrap: wrap;
* /
flex-flow: row wrap;
/ * Now it is significant how the space will be divided * /
}
Ready. Everything is different - the same design is on the right. Let's try something else.Please note that we need right-aligned navigation at the very top of our site, but we also want it to be center-aligned for medium-sized screens and transformed into one page for small screens.Everything is easy to complete.
/ * Great screens * /
.navigation(
display: flex;
flex-flow: row wrap;
/ * Destroys elements to the end of the row along the head axis * /
justify-content: flex-end;
}
media all and (max-width: 800px) (
.navigation(
/ * For medium-sized screens, navigation is centered,
evenly distributing space between the elements * /
justify-content: space-around;
}
}
/ * Small screens * /
media all and (max-width: 500px) (
.navigation(
/ * On small screens, replace the rows with their own ordered elements in the column * /
flex-direction: column;
}
}
Let's play with the flexibility of flex elements!How about a mobile-oriented three-column layout with a full-width header and footer?І in a different order of retouching.
Wrapper (
display: flex;
flex-flow: row wrap;
}
/ * Set the width of all elements to 100% * /
.header, .main, .nav, .aside, .footer (
flex 1100%;
}
/ * In which case we put the output order for orientation on
* Mobile devices:
* 1 header
* 2 nav
* 3 main
* 4 aside
* 5 footer
* /
/ * Screens of medium size * /
media all and (min-width: 600px) (
/ * Two sidebars are displayed in one row * /
.aside (flex: 1 auto;)
}
/ * Great screens * /
There is nothing to stand still, technologies and standards are developing, new techniques and methods of website layout are emerging, for example, layout with tabular elements, which we did not see due to objective reasons, changed the layout of floating elements.
With many code editors, or a manual plug-in for the Emmet format available for download, you can create the basic layout of your application in the following way: section> div * 3> lorem+ Tab (value lorem generates text like the one shown below).
Please note that without any special efforts we have taken away the placement of the columns of our layout of a new height regardless of the surface of their place and this is wonderful. elements
not woven with flex elements and reworked in the future third element
The result of our butt:
Row flex container
By analogy with block elements, flex containers can be small. Let's look at the importance of small flex containers versus block containers. At the front, we looked at the vertical structure of the block container, as the primary block element occupies the entire width of the screen, and behaves as a primary element equal to the block. When small flexible containers are used, they become the primary elements that are absorbed, thereby preserving the elasticity of the elements.
The front butt will have this significance, since the front butt will not be visible, for the same reason that the subsidiary flex elements are not clearly given size assignments, and as a result, our container, either in a row or in a block i borrowed the entire width of the screen.
Whose butts were placed two small ones two block flex containers, in the middle of them we placed five elements
To quickly generate a similar layout for help Emmet type in the editor next: div.inline-flex * 2> div * 5 + Tab, and the same with a different class div.flex * 2> div * 5 + Tab.
Take a look at the result of our example, the difference between small and block flex containers is now obvious to you. A row container operates as an input element and occupies the width required only by its child flex elements, and a block flex container, regardless of the size of its child flex elements, occupies the entire width of the screen.
The result of our butt:
Small 205 Application of the versatility of inline-flex containers versus flex containers.
Directly? Which one directly?
Flex elements are directly formed based on the position of two axes: head axis flex container iyogo transverse axis, Yak is the leader of roztashovaniy perpendicular to the head. The entire head, when directed by ltr (the global HTML attribute dir, which is the CSS power of direction with ltr values), is expanded to the right, and the transverse one is directed downward (meaning the same), for the rtl value it is displayed in a mirror image.
The align-content power specifies the type of alignment of the rows in the middle of the flex container along the transverse axis, providing plenty of space.
stagnate until: Flex container.
Significance for zamovchuvannyam: Stretch.
Flex-start The rows are spread on the cob of the transverse axis. The front row of the skin runs parallel to the front row. flex-end The rows are rotated starting from the end of the transverse axis. The front row of skin goes in line with the step. center The rows are arranged in the center of the container. space-between The rows are evenly distributed in the container and stand between them however. space-around The rows are evenly distributed in such a way that the space between the two rows is the same. The empty space in front of the first row and after the remaining row is the same half of the space between two rows of rows. space-evenly The rows are distributed evenly. The empty space before the first row and after the remaining row is the same width as the other rows. stretch The rows are evenly stretched, leaving plenty of space.
The align-content property aligns a flex container's lines within the flex container when there is extra space in the cross-axis, similar to how justify-content aligns individual items within the main-axis. Note, this property has no effect on a single-line flex container. Values have the following meanings:
Note: Only multi-line flex containers ever have free space in the cross-axis for lines to be aligned in, because in a single-line flex container the sole line automatically stretches to fill the space.
Applies to: Flex containers.
Initial: Stretch.
Flex-start Lines are packed toward the start of the flex container. The cross-start edge of the first line in the flex container is placed flush with the cross-start edge of the flex container, and each subsequent line is placed flush with the preceding line. flex-end Lines are packed toward the end of the flex container. The cross-end edge of the last line is placed flush with the cross-end edge of the flex container, and each preceding line is placed flush with the subsequent line. center Lines are packed toward the center of the flex container. The lines in the flex container are placed flush with each other and aligned in the center of the flex container, with equal amounts of space between the cross-start content edge of the flex container and the first line in the flex container, and between the cross-end content edge of the flex container and the last line in the flex container. (If the leftover free-space is negative, the lines will overflow equally in both directions.) Space-between Lines are evenly distributed in the flex container. If the leftover free-space is negative this value is identical to flex-start. Otherwise, the cross-start edge of the first line in the flex container is placed flush with the cross-start content edge of the flex container, the cross-end edge of the last line in the flex container is placed flush with the cross- end content edge of the flex container, and the remaining lines in the flex container are distributed so that the spacing between any two adjacent lines is the same. space-around Lines are evenly distributed in the flex container, with half-size spaces on either end. If the leftover free-space is negative this value is identical to center. Otherwise, the lines in the flex container are distributed such that the spacing between any two adjacent lines is the same, and the spacing between the first / last lines and the flex container edges is half the size of the spacing between flex lines. space-evenly Lines are evenly distributed in the flex container. If the leftover free-space is negative this value is identical to center. Otherwise, the lines in the flex container are distributed such that the spacing between every flex line is the same. stretch Lines stretch to take up the remaining space. If the leftover free-space is negative, this value is identical to flex-start. Otherwise, the free-space is split equally between all of the lines, increasing their cross size.
CSS flexbox (Flexible Box Layout Module)- a module for the layout of a bunk container - is a way of arranging elements, based on the idea of an axis.
Flexbox folds flex containerі flex items. The elements can be arranged in a row or stacked, and the space can be distributed between them in different ways.
The flexbox module allows you to customize the following:
- Rotate the elements in one of four directions: from left to right, from right to left, down or down up.
- Rearrange the order in which the elements are displayed.
- Automatically determine the dimensions of the elements so that they fit into the available space.
- Address the problem with horizontal and vertical centering.
- Transfer the elements to the middle of the container without allowing them to move around.
- Create columns of the same height.
- Close the ones squeezed to the bottom of the side.
Flexbox has specific tasks - the creation of one-dimensional layouts, for example, a navigation bar, since flex elements can only be placed along one axes.
You can read the list of exact problems of the module and cross-browser solutions for them in the article by Philip Walton.
What is flexbox?
Browser support
IE: 11.0, 10.0 -ms-
Firefox: 28.0, 18.0 -moz-
Chrome: 29.0, 21.0 -webkit-
Safari: 6.1 -webkit-
Opera: 12.1 -webkit-
iOS Safari: 7.0 -webkit-
Opera Mini: 8
Android Browser: 4.4, 4.1 -webkit-
Chrome for Android: 44
1. Basic concepts
![](https://i1.wp.com/html5book.ru/wp-content/uploads/2015/06/box-model.png)
A different set of terms is used to describe the Flexbox module. The flex-flow values and recording mode indicate the similarity of these terms in physical directions: top / right / bottom / left, axes: vertical / horizontal and dimensions: width / height.
Whole head (main axis)- all flex elements included. Vaughn extends mainly to the World.
Main start and main end- lines that indicate the end and end sides of the flex container, where flex elements are placed (starting from the main start and straight to the main end).
Main size) - the width or height of the flex container or flex elements, depending on what they are in the main world, indicate the main size of the flex container or flex element.
Cross axis- all, perpendicular to the head axis. Vaughn stretches in the transverse dimension.
Cross start and cross end- lines that indicate the front and end sides of the transverse axis, where flex elements are placed.
Cross size- the width or height of the flex container or flex elements, including what is in the transverse dimension, and their transverse size.
![](https://i1.wp.com/html5book.ru/wp-content/uploads/2019/02/flexbox-mode.jpg)
2. Flex container
The Flex container installs a new flexible formatting context for it instead. A flex container is not a block container, so CSS controls such as float, clear, vertical-align are not applied to child elements. Also, the flex container should not be injected with the power of column-*, which creates columns in the text and pseudo-elements :: first-line and :: first-letter.
The flexbox layout model is associated with the basic values of the CSS display power of the father's html element, which contains child blocks. To control elements of this model, you need to set the display power as follows:
Flex-container (/ * generates a block-level flex container * / display: -webkit-flex; display: flex;) .flex-container (/ * generates a row-level flex container * / display: -webkit-inline-flex; display: inline-flex;)
After setting this value for skin power, the child element automatically becomes a flex element, stacked in one row (along the head axis). When block and small child elements are created, however, the width of the blocks is the same as their width, instead of adjusting the internal margins and frames of the element.
![](https://i2.wp.com/html5book.ru/wp-content/uploads/2015/06/display-flex.png)
If Father's block replaces text or images without burns, they become anonymous flex elements. The text aligns with the top edge of the container block, and the height of the image becomes equal to the height of the block so that it is deformed.
3. Flex elements
Flex elements are blocks that are represented instead of a flex container in a workflow. The Flex container installs a new formatting context for itself, which includes the following features:
- For flex elements, their display power values are blocked. Display value: inline-block; i display: table-cell; calculated in display: block; .
- There is empty space between the elements, because nothing becomes its own flex element, so that inter-element text is wrapped in an anonymous flex element. For an anonymous flex element, it is not possible to set external styles, otherwise they will inherit them (for example, font parameters) from the flex container.
- A completely positioned flex element does not take part in the layout of a flex layout.
- The margins of lateral flex elements do not collapse.
- Percentage margin and padding values are calculated based on the internal size of their block.
- margin: auto; are expanding, fading the additional space in the similar world. They can be used for alignment or differentiation of existing flex elements.
- Automatic minimum size of flex elements after wrapping and the minimum size of them together, then min-width: auto; . For scrollable containers, the automatic minimum size is set to zero.
4. Order of display of flex elements and orientation
Instead of a flex container, you can lay it out in any direction and in any order (rearranging flex items in the middle of the container affects visual rendering).
4.1. Direction of the head axis: flex-direction
The power is transferred to the flex container. Controls the direction of the head axis, on which flex elements are placed, similar to the continuous recording mode. Chi does not subside.
flex-direction | |
---|---|
meaning: | |
row | Significance for washing, from left to right (in rtl from right to left). Flex elements are placed in a row. The cob (main-start) and the end (main-end) of the direction of the head axis correspond to the cob (inline-start) and the end (inline-end) of the row axis (inline-axis). |
row-reverse | Straight from right to left (in rtl left to right). Flex elements are placed in a row along the right edge of the container (in rtl - the left one). |
column | Straight down to the beast. Flex elements are placed in a column. |
column-reverse | A column with elements in reverse order, from bottom to top. |
initial | |
inherit |
![](https://i1.wp.com/html5book.ru/wp-content/uploads/2015/06/flex-direction.png)
syntax
Flex-container (display: -webkit-flex; -webkit-flex-direction: row-reverse; display: flex; flex-direction: row-reverse;)
4.2. Managing multiple row flex containers: flex-wrap
The power determines whether the flex container is single-row or multi-row, and also sets the direction of the transverse axis so that new lines of the flex container can be laid directly.
Behind the lining, the flex elements are laid in one row, around the head axis. If it is overfilled, the smell will go beyond the boundaries of the flex container. Power does not wane.
![](https://i0.wp.com/html5book.ru/wp-content/uploads/2015/06/flex-wrap.png)
syntax
Flex-container (display: -webkit-flex; -webkit-flex-wrap: wrap; display: flex; flex-wrap: wrap;)
4.3. Short recording of direct and bagatoryadkova: flex-flow
The power allows you to determine the direction of the head and transverse axes, as well as the ability to transfer flex elements, if necessary, to the rows. It is a short recording of the powers of flex-direction and flex-wrap. Meaning behind flex-flow: row nowrap; . power does not wane.
syntax
Flex-container (display: -webkit-flex; -webkit-flex-flow: row wrap; display: flex; flex-flow: row wrap;)
4.4. The order of display of flex elements: order
Authority refers to the order in which flex items are displayed and arranged in the middle of a flex container. Stick to flex elements. Power does not wane.
Initially, all flex elements are set to order: 0; . When entering a value of -1 for the element vin moves to the beginning of the term, a value of 1 - to the end. If a number of flex items have the same order values, they will appear in the same order.
syntax
Flex-container (display: -webkit-flex; display: flex;).flex-item (-webkit-order: 1; order: 1;) Small 6. Order of display of flex elements
5. Flexibility of flex elements
The primary aspect of a flexible layout is the ability to “flex” flex items by changing their width/height (including what size is on the head axis) to accommodate the memory available in the main layout. Try for additional power flex. The flex container allocates ample space between its child elements (proportional to their flex-grow coefficient) to fill the container or compresses them (proportional to their flex-shrink coefficient), so get around the world.
The flex element will be completely “non-flexible” if its flex-grow and flex-shrink values reach zero, and “flexible” in another case.
5.1. The conquest of small sizes by one power: flex
Power is a shorthand version of power: flex-grow, flex-shrink and flex-basis. Values for the settings: flex: 0 1 auto; . You can indicate either one or all three meanings of power. Power does not wane.
syntax
Flex-container (display: -webkit-flex; display: flex;).flex-item (-webkit-flex 3 1 100px; -ms-flex 3 1 100px; flex 3 1 100px;)
5.2. Growth coefficient: flex-grow
Power refers to the ratio of growth of one flex element to other flex elements in a flex container while distributing positive free space. If the value of flex-grow flex elements in a row is less than 1, they occupy less than 100% of the available space. Power does not wane.
![](https://i2.wp.com/html5book.ru/wp-content/uploads/2019/03/flex-grow-navbar.png)
syntax
Flex-container (display: -webkit-flex; display: flex;).flex-item (-webkit-flex-grow: 3; flex-grow: 3;)
5.3. Shrinkage ratio: flex-shrink
Power indicates the coefficient of compression of a flex element compared to other flex elements when distributing negative free space. Multiply by the base size flex-basis. The negative space is proportional to how much the element can be compressed, so, for example, a small flex element will not change to zero until a larger flex element changes. Power does not wane.
![](https://i2.wp.com/html5book.ru/wp-content/uploads/2015/06/flex-shrink.png)
syntax
Flex-container (display: -webkit-flex; display: flex;).flex-item (-webkit-flex-shrink: 3; flex-shrink: 3;)
5.4. Basic size: flex-basis
The authority sets the initial basic size of the flex element to the division of the free space according to the flexibility coefficients. For all values, except auto and content, the basic size is determined as width in horizontal recording modes. Percentage values are based on the size of the flex container, and if the size is not the task, the values for the flex-basis are based on the size of it instead. Chi does not subside.
syntax
Flex-container (display: -webkit-flex; display: flex;).flex-item (-webkit-flex-basis: 100px; flex-basis: 100px;)
6. Virus bath
6.1. Verification along the cephalic axis: justify-content
The power of the flex elements is aligned along the head axis of the flex container, distributing ample space, do not occupy it with flex elements. When an element is converted into a flex container, the flex elements are grouped together (as they do not have margin fields specified). Gaps are added after expanding the margin and flex-grow values. If any elements have zero values, flex-grow or margin: auto; , Power will not flow in. Power does not wane.
meaning: | |
flex-start | Significance for zamovchuvannyam. Flex elements are laid in a straight line that goes out from the cob line of the flex container. |
flex-end | Flex elements are laid straight out from the end line of the flex container. |
center | Flex elements are aligned in the center of the flex container. |
space-between | Flex elements are distributed evenly along the line. The first flex element is placed flush with the edge of the cob line, the remaining flex element is placed flush with the edge of the end line, and the flex elements on the line are divided so that Well, what two natural elements were, however. There is only one flex element in the row, and the value is identical to the flex-start parameter. |
space-around | Flex elements on the line are distributed so that the space between two adjacent flex elements is the same, and the space between the first/remaining flex elements and the edges of the flex container is half the distance between the flex elements cops. |
initial | It establishes the importance of power in the meaning of power. |
inherit | The decline in the importance of power from the Fatherland element. |
![](https://i2.wp.com/html5book.ru/wp-content/uploads/2015/06/justify-content.png)
syntax
Flex-container (display: -webkit-flex; -webkit-justify-content: flex-start; display: flex; justify-content: flex-start;)
6.2. Alignment along the transverse axis: align-items and align-self
Flex elements can be aligned along the transverse axis of the flow row of the flex container. align-items sets the alignment for all flex container items, including anonymous flex items. align-self allows you to re-value the value for multiple flex elements. Even though the transverse margin of the flex element has the value auto, align-self does not have any influx.
6.2.1. Align-items
The power of vertical flex elements, including anonymous flex elements along the transverse axis. Chi does not subside.
meaning: | |
flex-start | |
flex-end | |
center | |
baseline | The base lines of all flex elements that take part in the verification are avoided. |
stretch | |
initial | It establishes the importance of power in the meaning of power. |
inherit | The decline in the importance of power from the Fatherland element. |
![](https://i2.wp.com/html5book.ru/wp-content/uploads/2015/06/align-items.png)
syntax
Flex-container (display: -webkit-flex; -webkit-align-items: flex-start; display: flex; align-items: flex-start;)
6.2.2. Align-self
Power indicates the alignment of the selected flex element according to the height of the flex container. Revalues the alignment of tasks align-items. Chi does not subside.
meaning: | |
auto | Significance for zamovchuvannyam. The flex element is vicoristic, assigned to the power of the align-items flex container. |
flex-start | The top edge of the flex element should be located next to the flex line (or on the side, with the settings of the margin and frame border element) to pass through the cob of the transverse axis. |
flex-end | The bottom edge of the flex element is located next to the flex line (or on the side, with the settings of the margin fields and border frames of the element), which passes through the end of the transverse axis. |
center | The margins of a flex element are centered along the transverse axis between the flex lines. |
baseline | The flex element is aligned along the base line. |
stretch | Since the transverse size of a flex element is calculated as auto, and even from the transverse margin value is not equal to auto, the element stretches. Significance for zamovchuvannyam. |
initial | It establishes the importance of power in the meaning of power. |
inherit | The decline in the importance of power from the Fatherland element. |
![](https://i1.wp.com/html5book.ru/wp-content/uploads/2015/06/align-self.png)
syntax
Flex-container (display: -webkit-flex; display: flex;).flex-item (-webkit-align-self: center; align-self: center;)
6.3. Variation of flex container rows: align-content
The power of aligned rows in a flex container with the presence of additional space on the transverse axis is similar to the alignment of adjacent elements on the head axis for the additional power of justify-content. Power does not flow into a single-row flex container. Chi does not subside.
meaning: | |
flex-start | The rows are laid straight up to the cob of the flex container. The edge of the first row is placed flush against the edge of the flex container, the skin is placed flush against the front row. |
flex-end | The rows are laid straight to the end of the flex container. The edge of the remaining row is placed against the edge of the flex container, the front skin is placed against the next row. |
center | The rows are laid straight to the center of the flex container. The rows are laid out one by one and aligned in the center of the flex container with an even edge between the cob edge instead of the flex container and the first row and between the end edge instead of the flex container and the remaining row com. |
space-between | The rows are evenly distributed in the flex container. The large space is negative or there is only one flex line in the flex container, and the value is identical to flex-start. In another case, the edge of the first row is placed flush to the end edge instead of the flex container, the edge of the remaining row is placed flush to the end edge instead of the flex container. Rearrange the rows of divisions so that there is a line between any two rows of rows. |
space-around | The rows are evenly distributed in flex containers with half spacing at both ends. Since the open space is negative, the value is identical to the center center. In another case, the rows are distributed in such a way that the space between any two rows is the same, and the line between the first/remaining rows and the edges instead of the flex container becomes half the size of the line in rows. |
stretch | Significance for zamovchuvannyam. The rows of flex elements stretch evenly, covering the entire available space. If the free space is negative, the meaning is identical to flex-start. Otherwise, the free space will be divided equally between rows larger than their transverse dimensions. |
initial | It establishes the importance of power in the meaning of power. |
inherit | The decline in the importance of power from the Fatherland element. |
![](https://i1.wp.com/html5book.ru/wp-content/uploads/2015/06/align-content.png)
syntax
Flex-container (display: -webkit-flex; -webkit-flex-flow: row wrap; -webkit-align-content: flex-end; display: flex; flex-flow: row wrap; align-content: flex-end ; height: 100px;)