Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprende flex-direction Property | Understanding Flexbox Basics
CSS Flexbox Foundations

bookflex-direction Property

The flex-direction property is a key part of the Flexbox model, letting you control the direction in which flex items are laid out along the main axis. By default, the main axis runs horizontally from left to right, but you can change this with flex-direction. There are four possible values for this property:

  • row: items are placed in a horizontal line from left to right;
  • row-reverse: items are placed in a horizontal line but in reverse order, from right to left;
  • column: items are stacked vertically from top to bottom;
  • column-reverse: items are stacked vertically, but in reverse order, from bottom to top.

Choosing the right direction not only affects the orientation of your items but also determines which edge is considered the start and end of the main axis. This impacts how other properties like alignment and ordering behave.

index.html

index.html

copy

When you use row-reverse, as shown above, the flex container arranges the items horizontally but in the opposite order. Instead of appearing as "1 2 3" from left to right, the items appear as "3 2 1" from right to left. The main axis still runs horizontally, but its starting point is switched to the right edge of the container.

Similarly, if you use column-reverse, items stack vertically, but from bottom to top, reversing both their order and the direction of the main axis. This reversal changes which side is considered the start and end for alignment and positioning, so understanding how these values affect the layout is essential for building flexible and dynamic interfaces.

question mark

Which of the following are valid values you can use with the flex-direction property, and how do they affect the arrangement of flex items?

Select the correct answer

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 1. Capítulo 3

Pregunte a AI

expand

Pregunte a AI

ChatGPT

Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla

Awesome!

Completion rate improved to 7.69

bookflex-direction Property

Desliza para mostrar el menú

The flex-direction property is a key part of the Flexbox model, letting you control the direction in which flex items are laid out along the main axis. By default, the main axis runs horizontally from left to right, but you can change this with flex-direction. There are four possible values for this property:

  • row: items are placed in a horizontal line from left to right;
  • row-reverse: items are placed in a horizontal line but in reverse order, from right to left;
  • column: items are stacked vertically from top to bottom;
  • column-reverse: items are stacked vertically, but in reverse order, from bottom to top.

Choosing the right direction not only affects the orientation of your items but also determines which edge is considered the start and end of the main axis. This impacts how other properties like alignment and ordering behave.

index.html

index.html

copy

When you use row-reverse, as shown above, the flex container arranges the items horizontally but in the opposite order. Instead of appearing as "1 2 3" from left to right, the items appear as "3 2 1" from right to left. The main axis still runs horizontally, but its starting point is switched to the right edge of the container.

Similarly, if you use column-reverse, items stack vertically, but from bottom to top, reversing both their order and the direction of the main axis. This reversal changes which side is considered the start and end for alignment and positioning, so understanding how these values affect the layout is essential for building flexible and dynamic interfaces.

question mark

Which of the following are valid values you can use with the flex-direction property, and how do they affect the arrangement of flex items?

Select the correct answer

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 1. Capítulo 3
some-alt