Back to CSS Notes
Topic #172

Flex Container

The flex container turns children into flexible items with main and cross axes. Understanding the axes is the whole trick to flexbox.


CSS Flex Container Properties

The flex container element can have the following properties:

  • display - Must be set to flex or inline-flex
  • flex-direction - Sets the display-direction of flex items
  • flex-wrap - Specifies whether the flex items should wrap or not
  • flex-flow - Shorthand property for flex-direction and flex-wrap
  • justify-content - Aligns the flex items when they do not use all available space on the main-axis (horizontally)
  • align-items - Aligns the flex items when they do not use all available space on the cross-axis (vertically)
  • align-content - Aligns the flex lines when there is extra space in the cross axis and flex items wrap

CSS flex-direction Property

The flex-direction property specifies the display-direction of flex items in the flex container.

This property can have one of the following values:

  • row (default)
  • column
  • row-reverse
  • column-reverse

Example

  .flex-container {

  display: flex;

  flex-direction: row;
}

Example

  .flex-container {

  display: flex;

  flex-direction: column;
}

Example

  .flex-container {

  display: flex;

  flex-direction: row-reverse;
}

Example

  .flex-container {

  display: flex;

  flex-direction: column-reverse;
}

CSS flex-wrap Property

The flex-wrap property specifies whether the flex items should wrap or not, if there is not enough room for them on one flex line.

This property can have one of the following values:

  • nowrap (default)
  • wrap
  • wrap-reverse

Example

  .flex-container {

  display: flex;

  flex-wrap: nowrap;
}

Example

  .flex-container {

  display: flex;

  flex-wrap: wrap;
}

Example

  .flex-container {

  display: flex;

  flex-wrap: wrap-reverse;
}

CSS flex-flow Property

The flex-flow property is a shorthand property for setting both the flex-direction and flex-wrap properties.

Example

  .flex-container {

  display: flex;

  flex-flow: row wrap;
}

Flex Container Subpages

Continue learning about flex container properties:

  • justify-content - horizontal alignment of flex items
  • align-items & align-content - vertical alignment and true centering

Want to go beyond the notes?

Join Coding Now Tech Institute's CSS course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

Flex Container – FAQs

Quick answers about learning Flex Container in CSS.

This free note from Coding Now Tech Institute explains Flex Container in CSS — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every CSS topic on Coding Now Tech Institute, including Flex Container, is 100% free with no signup required.
With focused practice, most students grasp Flex Container in 1–3 days from these notes; pairing it with Coding Now Tech Institute's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the Coding Now Tech Institute Community (/community) — expert instructors answer within 24 hours.
Call NowEnroll Now