What is a cross axis in Flexbox?
Experience Level: Junior
Tags: CSSFlexbox
Answer
In Flexbox, the cross axis is an axis that is perpendicular to the main axis.
The flex-direction: row
defines the direction of the main axis to be horizontal. The cross axis will then be vertical.
The flex-direction: column
defines the direction of the main axis to be vertical. The cross axis will then be horizontal.
The cross axis for the following CSS will be vertical:
div {
display: flex;
flex-direction: row;
}
The cross axis for the following CSS will be horizontal:
div {
display: flex;
flex-direction: column;
}
Related Flexbox job interview questions
How can you make flex container items that flow from left to right to fill all space from top to bottom?
CSSFlexbox JuniorWhat is the CSS property align-items used for and what values can it have?
CSSFlexbox JuniorHow would you use space-between and what do you know about it?
CSSFlexbox JuniorWhy would you use flex-wrap CSS property and what values can it have?
CSSFlexbox JuniorWhen would you use flex-flow property and what is it good for?
CSSFlexbox Junior