bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths
Learn/CSS/Modern Layout
CSS•Modern Layout

CSS Flex Container

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
row
column
row-reverse
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
nowrap
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

Formatted code
.flex-container {
  display: flex;
  flex-flow: row wrap;
}

Live preview

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

Previous

Responsive Web Design

Next

CSS Grid Container

This chapter

Overview
24

Lessons

64m

Read time

1. CSS Flexbox2. CSS Grid Layout3. Responsive Web Design4. CSS Flex Container5. CSS Grid Container6. Responsive Web Design - The Viewport7. CSS Flexbox justify-content8. CSS Grid Tracks9. Responsive Web Design - Building a Grid View10. CSS Flexbox Align11. CSS Grid Gap12. Responsive Web Design - Media Queries13. CSS Flex Items14. CSS Grid Container - Align Grid Content15. Responsive Web Design - Images16. CSS Responsive Flexbox17. CSS Grid Items18. Responsive Web Design - Frameworks19. CSS Naming Grid Items20. Responsive Web Design - Templates21. CSS Grid Items - Alignment22. CSS Grid Items - Order23. CSS 12-Column Grid Layout24. CSS @supports Rule

On this page

CSS Flex Container PropertiesCSS flex-direction PropertyCSS flex-wrap PropertyCSS flex-flow PropertyFlex Container Subpages