

Note: other properties don't have default values. Also, if some items have a bigger height than others, smaller items stretch to fit the highest item. When there are more items than the container can have, they overflow (not wrap). The container distributes its items in a row, and the size of content determines their size on the main axis. The flex container either expands items to fill available space or makes them smaller to avoid overflow.Įvery flex container initially has these default values:

Tip: the children of both inline-flex container and block flex container behave the same. Therefore, the CSS flex container defines the size, alignment, and position for its children. Then, all children of the container become flex items. The CSS flex container is the element that has a display property set to either flex or inline-flex. Note: understanding the axes of CSS flexbox is essential as CSS align and justifies flex items along them. If the main axis has a row or row-reverse direction, the cross axis runs along a column or column-reverse direction (and vice versa). Cross axis always goes perpendicular ( ⟂ ) to the main axis.column and column-reserve move from the top to bottom. Note: when set to row or row-reverse, the main axis moves along the row inline. It has four possible values: row, row-reverse, column, and column-reverse. You define the main axis with the flex-direction property.The CSS flexbox has two axes: the main and the cross. The items' ability to grow or shrink when the window resizes.The Justification of items and space in between.The wrapping of items when the window is resized.The direction to which the items are displayed.The CSS flexbox can control the following aspects of the layout:

These properties allow organizing items inside the container (some apply to parent elements others apply to the children). Therefore, it does not lay out items on both vertical and horizontal dimensions simultaneously.Īssigning properties to the parent element is more productive than assigning them to each child element individually. Remember: the CSS flexbox is one-dimensional.
