This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

flex-direction

Summary

The flex-direction CSS property describes how flex items are placed in the flex container, by setting the direction of the flex container’s main axis.

Overview table

Initial value
row
Applies to
flex containers
Inherited
No
Media
visual
Computed value
specified value
Animatable
No
CSS Object Model Property
flexDirection

Syntax

  • flex-direction: column
  • flex-direction: column-reverse
  • flex-direction: row
  • flex-direction: row-reverse

Values

row
The flex container’s main axis has the same orientation as the inline axis of the current writing mode. The main-start and main-end directions are equivalent to the start and end directions, respectively, of the current writing mode.
row-reverse
Same as 'row’, except the main-start and main-end directions are swapped.
column
The flex container’s main axis has the same orientation as the block axis of the current writing mode. The main-start and main-end directions are equivalent to the before/head and after/foot directions, respectively, of the current writing mode.
column-reverse
Same as 'column’, except the main-start and main-end directions are swapped.

Examples

Displaying children in a row

.list {
  display: flex;
  flex-direction: row;
}

.list div {
  flex: 1;
}

View live example

Displaying children in a row in reversed order

.list {
  display: flex;
  flex-direction: row-reverse;
}

.list div {
  flex: 1;
}

View live example

Displaying children in a column

.list {
  display: flex;
  flex-direction: column;
}

.list div {
  flex: 1;
}

View live example

Displaying children in a column in reversed order

.list {
  display: flex;
  flex-direction: column-reverse;
}

.list div {
  flex: 1;
}

View live example

Notes

The reverse values do not reverse box ordering; like ‘writing-mode’ and ‘direction’, they only change the direction of flow. Painting order, speech order, and sequential navigation orders are not affected.

Related specifications

CSS Flexible Box Layout Module
Candidate Recommendation

See also

Related articles

Flexbox