On the cross axis of a flexbox align-self
can control the alignment of individual items. There is no
equivalent justify-self
property for the main axis. Instead you can achieve this by setting
margin: auto
on items. Free space is essentially divided up between margin: auto
s.
Adding left margin to the rightmost element pushes it to the right:
Adding both margins centers the element in the free space:
Multiple elements with margins will divide the free space between them:
It doesn't matter which element the margin is assigned to:
If two elements have a margin in the same space they each get a share of the divided space, they don't combine together: