justify-content
aligns a list’s content salong the main axis of a flex container by distributing space between or around items.
It has six different values that change how the list is aligned:
flex-start
– this is the default value, it positions the items at the start of the container.flex-end
– positions the items at the end of the container.center
– places items in the center.space-around
– places items with space distributed evenly around the start and end of the list.space-between
– evenly distributes space items between the first item is set at the start of the container, and the last item is set at the end.space-evenly
– spaces items such that they have equal amounts of space before and after them.The following example demonstrates justify-content
:
Here, justify-content
has been used in the following order:
flex-start
flex-end
center
space-around
space-between
space-evenly
In order to use justify-content
, all you need is the justify-content: desired value
and display: flex
properties. The rest are just for styling.
Free Resources