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.

butt

a cap
Stattya
basement

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