Skip to main content

Command Palette

Search for a command to run...

CSS Flexbox

Published
•3 min read•View as Markdown
CSS Flexbox

what is flexbox?

Flexbox is a one-dimensional layout method for arranging items in rows or columns. Flexbox is a layout model that enables efficient and dynamic element arrangement. This one-dimensional layout allows elements to be placed inside a container with evenly distributed space.

  • flexbox properties : -

  • Display property :-

The flex container become flexible by setting the display property to flex.

flex..png

  • Flex direction property :-

The flex-direction CSS property sets how flex items are placed in the flex container defining the main axis and the direction (normal or reversed).

in flex direction it have so many types -

  • row - it represents horizantally left to right.

row.png

  • row-reverse - it represents horizontally right to the left.

row-reverse.png

  • column - it represents vertically top to bottom.

column.png

  • column reverse - it is also same as column but bottom to top.

column-reverse.png

flex wrap property -

The flex-wrap CSS property sets whether flex items are forced onto one line or can wrap onto multiple lines. If wrapping is allowed, it sets the direction that lines are stacked.

  • wrap - whether flex items are forced onto one line or can wrap onto multiple lines.

wrap.png

  • no-wrap The No-wrap CSS property sets whether flex items are forced onto one line..

nowrap.png

  • wrap-reverse it will wrap onto bottom to top

wrap-reverse.png

  • Align-item Property -

The align-item In Flexbox, it controls the alignment of items on the Cross Axis. In Grid Layout, it controls the alignment of items on the Block Axis within their grid area.

  • center - To center our box we use the align-items property to align our item on the cross axis.

align center.png

  • flex-start items are placed at start of the cross-axis

flex-start.png

  • flex-end items are placed at end of the cross-axis

flex-end.png

  • stretch controll all items in the cross-axis

stretch.png

  • baseline items are aligned such as their baselines align

baseline.png

  • justify-content

    The justify-content property is a sub-property of the Flexible Box Layout module. It defines the alignment along the main axis.

  • center - it centered the items in main-axis

justify-center.png

  • flex-start items are moved towards start line.

justify-start.png

  • flex-end items are moved towards end line.

justify-end.png

  • space-around space-around places items with space distributed evenly around the start and end of the list.

space-around.png

  • space-between
    space-between evenly distributes space items between the first item is set at the start of the container, and the last item is set at the end.

space-between.png