-1

For CSS Flexbox layouts, I have been given to understand that we have align-items property to align our item on the cross axis, while we use justify-content to align the item on the main axis.

Now does the above statement applicable only with the default flex-direction i.e. row

Does it change when we use flex-direction as column.

So essentially, I am confused with how the behavior of align-items and justify-content when we have flex-direction as column ?

Example

On following link https://jsbin.com/wakagup/edit?html,output

.box {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
  }

If we change align-items from flex-start to flex-end, the divs seem to move horizontally rather than vertically which is what is confusing me.

Also, the divs move differently when we remove flex-direction: column; and try different values for the align-items/justify-content

copenndthagen
  • 49,230
  • 102
  • 290
  • 442

1 Answers1

0

When the direction is inverted the axis inverts thus the opposite behavior.

The flex-direction CSS property sets how flex items are placed in the flex container defining the main axis and the direction (normal or reversed). - MDN

Sai Krishna
  • 597
  • 4
  • 16