What is a CSS flexbox?

A flexbox provides powerful alignment options by giving the user control over properties like alignment, order, and direction.

Some terminology:

  • flex container: groups flex items together to control their representation.
  • flex items: direct children of the flex container.

Properties

There are six container properties:

  • flex-direction
  • flex-wrap
  • justify-content
  • align-items
  • flex-flow
  • align-content

Let’s see how each of these properties are used:

flex-direction

Determines the direction in which the items ne​ed to be placed.

flex-wrap

Defines if items should wrap or not.

justify-content

Aligns the items.

align-items

Aligns the items vertically.

flex-flow

Sets the flex-wrap and flex-direction together.

align-content

Aligns the flex lines.

To learn more, refer to the official documentation.

Free Resources

Copyright ©2024 Educative, Inc. All rights reserved