Introduction To Flexbox
Introduction To Flexbox
Definition:
• Flexbox is short for the Flexible Box Layout module.
• Flexbox is a layout method for arranging items in rows or columns.
• It is used for one-dimensional layout
Use of Flexbox:
• Align items horizontally or vertically
• Distribute space within a container
• Create responsive designs without floats or positioning hacks
A flex container with three flex items
<div class="flex-container">
<div>1</div>
<div>2</div>
<div>3</div>
</div>
•row
•column
•row-reverse
•column-reverse
Flex-wrap
The flex-wrap property specifies whether the flex items should wrap or not.
The flex-wrap property can have one of the following values:
•nowrap
•wrap
•wrap-reverse
Justify-content
The justify-content property is used to align the flex items when
they do not use all available space on the main-axis (horizontally).
The justify-content property can have one of the following values:
•center
•flex-start
•flex-end
•space-around
•space-between
•space-evenly
Align-items
The align-items property is used to align the flex items when they do not use all
available space on the cross-axis (vertically).
The align-items property can have one of the following values:
•center
•flex-start
•flex-end
•stretch
•baseline
•normal
Align-content
The align-content property is used to align the flex lines.
The align-content property can have one of the following values:
•center
•stretch
•flex-start
•flex-end
•space-around
•space-between
•space-evenly
CSS Flex Items
The direct child elements of a flex container automatically becomes flex items.
The CSS properties we use for flex items are:
• order
• flex-grow
• flex-shrink
• flex-basis
• flex
• align-self