Guide on CSS FlexBox

Guide on CSS FlexBox

·

3 min read

Flexbox has change the way we write css code. Flexbox has actually made css code much easy, simply and understandable. It also handle responsiveness of the website. It provides built-in support for responsiveness of webpage

Flexbox stands for flexible box. It provides an easy and efficient way to align items in a container.

Flexbox is used for building one-dimensional layouts.The Flexbox also known as Flexible Box Module is a web layout model.

The two axes of Flexbox.

When working with flexbox you need to think in terms of two axes — the main axis and the cross axis.

  1. Main-axis

Axis along which we are trying to align our flex items. The main axis is defined by the flex-direction property

  1. Cross-axis

The cross axis runs perpendicular to main axis. if main axis is selected as row then cross axis will be column.

Flex Direction

Flexbox's main axis is defined by the flex-direction property, which has four possible values that determine the direction towards which the flex items will be placed within the flex container:

Flex-Wrap

By default, flex items will all try to fit into single line. We can change that and allow the items to wrap as needed with this property.

Justify-Content

The CSS justify-content property defines how the browser distributes space between and around content items along the main-axis of a flex container, and the inline axis of a grid container.Values of justify-content are:

Align-Items

In Flexbox, align-items controls the alignment of items on the Cross Axis.