

If multi-line is enabled in the container, this property also allows you to control the direction in which the flex elements are placed. Properties Usedĭisplay property defines how a particular HTML element should be displayed.įlex-direction property indicates the direction in which the flex elements are located inside the container.įlex-wrap property determines whether the flex container will be single-line or multi-line. Not meant to be a cure-all for every layout issue. Like any tool, flexbox has its place in your toolbox, but it's Is vertical (top to bottom) What isn't Flexbox? (left to right unless the direction is set rtl) and the cross direction If we have the flex-direction set to row, the main axis is horizontal The cross axis is the axis perpendicular to the main axis. The main axis is the axis along which the flex items follow each other. Every flexible box layout follows two axes. Any elements within that container are nowĪutomatically flex-items. Items expand and shrink to fill the available space.įlexbox content begins with a container whose display property is Width, height and order to best fill the available space. The "flex" in flexbox comes from its ability to alter its items'

Note that someīrowsers need prefixes to use these features. Margins don't collapse with the margins of its contents. Flexbox does not rely on floats and margins, and the flex container's Justify-content property flex-start flex-end center space-between space-aroundįlexbox is a way to layout elements to accommodate different screen In the flex container above, the cross axis is indicatedīy a green arrow in the upper right corner. Will be reversed if the direction property is rtl. Nowrap, flex items will be added to fit theįlex container and overflow the container if the flex itemsĬan't be shrunk to fit. To right ( wrap-reverse would make flex items Is set to wrap, flex items will wrap from left To bottom ( wrap-reverse would make flex items Set to wrap, flex items will wrap from top While setting the direction of the cross axis in the process. Setting the flex-wrap propertyĪllows content to wrap onto multiple lines (rows or columns)

By default, flex items are laid out in a single line
