Skip to main content

How do you set the direction of the main axis?

In Flexbox, the direction of the main axis is set by the property:

javascript
flex-direction

Options:

javascript
flex-direction: row; /* main axis - horizontal (left to right) */ flex-direction: row-reverse; /* horizontal, but in the reverse direction */ flex-direction: column; /* main axis - vertical (top to bottom) */ flex-direction: column-reverse; /* vertical, but in the reverse direction */

The main axis changes depending on the chosen value of flex-direction.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.

How do you set the direction of the main axis?: CSS Interview Question