Both set the alignment of the content.
1. justify-content: along primary axis
(set horizontal alignment/spacing if flex-direction is row or vertical alignment/spacing if flex-direction is column)
For instance, if flex-direction is row (default):
flex-start; Align children horizontally left
flex-end; Align children horizontally right
center; Align children horizontally centered (amaze!)
space-between; Distribute children horizontally evenly across entire width
space-around; Distribute children horizontally evenly across entire width (but with space on the edges
2. align-items: along secondary axis
(set vertical alignment if flex-direction is row or horizontal alignment if flex-direction is column)
For instance, if flex-direction is row (default):
flex-start; Align children vertically top
flex-end; Align children vertically bottom
center; Align children vertically centered (amaze!)
baseline; Aligned children vertically so their baselines align (doesn't really work)
stretch; Force children to be height of container (great for columns)
See it in action:
http://codepen.io/enxaneta/full/adLPwv/
In my opinion:
These should have been named:
flex-x: alignment/spacing in primary axis
flex-y: alignment in secondary axis
But with HTML you can never have nice things. Never.
Answer from Robot on Stack OverflowVideos
https://codepen.io/cgregurich/pen/jOBEZXb
I'm trying to understand flex box and stuff, and I'm very confused by align-content vs align-items and justify-content vs justify-items.
I don't think my confusion has much to do with understanding the different between align VS justify, but rather the difference between items and content.
Mainly the fact that to get this to display as I want (numbers in the center of the boxes), I have to use justify-content and align-items, but if I were to use justify-items and align-content then it doesn't work as desired.
Why?