Advanced Positioning
Last updated
Was this helpful?
Last updated
Was this helpful?
Provides a more efficient way to layout, align, and distribute space among items in a container, even when their size is unknown and/or dynamic.
The main idea behind the flex layout is to give the container the ability to alter its items' width/height (and order) to best fill the available space (mostly to accommodate all kinds of display devices and screen sizes).
After setting the CSS to use flexbox, the positioning changes as follows.
Flexbox properties can be categorized into 2 main types:
Container properties (flex-direction, flex-wrap, justify-content, align-items, align-content)
Flex Item properties (order, flex, flex-grow, flex-shrink, align-self)
Flex Container: This refers to the container that has display: flex; set to it.
Flex Item: These are the individual children inside of the Flex Container
Main-axis: By default is set from left to right.
Cross-axis: By default is set from top to bottom.
As soon as display: flex is set on a container, these imaginary axes are going to work together to determine how the flex items inside of the flex container should move around and behave.
Here is an example:
More details and examples below:
Another external resource: