Flexible boxes, or flexbox, is a new layout mode in CSS3. Flexbox provides tools to allow rapid creation of complex, flexible layouts, and features that historically proved difficult with CSS. Use of flexbox ensures that elements behave predictably when the page layout must accommodate different screen sizes and different display devices.
For a long time, the only reliable cross browser-compatible tools available for creating CSS layouts were things like floats and positioning. These are fine and they work, but in some ways, they are also rather limiting and frustrating.
The following simple layout requirements are either difficult or impossible to achieve with such tools, in any kind of convenient, flexible way:
- Vertically centering a block of content inside its parent.
- Making all columns in multiple column layouts adopt the same height even if they contain a different amount of content.
- Making all the children of a container take up an equal amount of the available width/height, regardless of how much width/height is available.
- Flexbox makes a lot of layout tasks much easier.
For many applications, the flexible box model provides an improvement over the block model in that it does not use floats, nor do the flex container’s margins collapse with the margins of its contents.
CSS3 Flexbox Concepts:-
Flexbox consists of flex containers and flex items. A flex container is declared by setting the display property of an element to either flex (rendered as a block) or inline-flex (rendered as inline) and inside a flex container, there are one or more flex items.
In the flexbox layout system, we have to declare a parent div with a CSS property display: flex, which allows you to control how you want to position its children elements
This establishes the main-axis, thus defining the direction flex items are placed in the flex container. Flexbox is (aside from optional wrapping) a single-direction layout concept. Think of flex items as primarily laying out either in horizontal rows or vertical columns.
This defines the alignment along the main axis. It helps distribute extra free space left over when either all the flex items on a line are inflexible, or are flexible but have reached their maximum size. It also exerts some control over the alignment of items when they overflow the line.
Flex items are positioned inside a flex container along a flex line. By default, there is only one flex line per flex container. The following example shows three flex items. They are positioned by default: along the horizontal flex line, from left to right:
Example 2: The Second example shows the result of using the column value:
Note : Find more information on flex from css-tricks.com