basics

default, display: block

A
B
Cat

flex

A
B
Cat

flex, gap

A
B
Cat

wrap, shrink, grow

no wrap, items will shrink if not enough space

A
B
Cat
A
B
Cat
A
B
Cat
A
B
Cat

no wrap, but items are flex-shrink: 0, overflows if not enough space

A
B
Cat
A
B
Cat
A
B
Cat
A
B
Cat

no wrap, all items are flex-shrink: 0, but container is overflow: hidden

A
B
Cat
A
B
Cat
A
B
Cat
A
B
Cat

no wrap, all items are flex-shrink: 0, but container is overflow: auto

A
B
Cat
A
B
Cat
A
B
Cat
A
B
Cat

with wrap, items will move to next row if not enough space

A
B
Cat
A
B
Cat
A
B
Cat
A
B
Cat

with wrap, last Cat is flex-grow: 1

A
B
Cat
A
B
Cat
A
B
Cat
A
B
Cat

with wrap, all items are flex-grow: 1

A
B
Cat
A
B
Cat
A
B
Cat
A
B
Cat

items have flex-grow: 1, they grow to consume extra space

A
B
Cat

A & B are flex-grow: 1, Cat is flex-grow: 0.5

A
B
Cat

justify-content

justify-content: center, works along major axis, in this case horizontal;
note: no flex-grow here

A
B
Cat

justify-content: space-around

A
B
Cat

justify-content: space-evenly

A
B
Cat

justify-content: space-between

A
B
Cat

justify-content: start (default)

A
B
Cat

justify-content: end

A
B
Cat

align-items

align-items: center, works along minor axis, in this case vertical;
note: no visible effect because container height is just enough to accommodate items

A
B
Cat

align-items: center, container is taller

A
B
Cat

align-items: center, Cat is flex-grow: 1

A
B
Cat

align-items: center, justify-content: center

A
B
Cat

flex-direction: column

container height is not specified

A
B
Cat

container height 200px, items shrink

A
B
Cat
A
B
Cat

container height 200px, items have flex-shrink: 0, Cat is deeppink and hidden underneath next content

A
B
Cat
200x200 image here

container height 200px, items have flex-shrink: 0, Cat is deeppink and z-index: 1 to bring it on top layer

A
B
Cat
200x200 image here

container height 200px with flex wrap, items have flex-shrink: 0

A
B
Cat

container height 200px without flex-wrap but overflow: auto, items have flex-shrink: 0,

A
B
Cat

justify-content (vertical), align-items (horizontal)

justify-content: center

A

justify-content: center, align-items: center

A