Auto Margins in Flexbox: A Quick Refresher
The behavior has been written up before, but Chris Coyier revisits it after seeing recurring confusion and another developer's own attempt at an explanation. The setup is simple: a flex container holding items that don't fill the whole area.
Pushing an item to the far edge
To move an item — say, a "Menu" entry — all the way to the right, apply margin-left: auto;. The item will push as far away as it possibly can on that row.
Coyier suggests margin-inline-start: auto; as the better habit — logical properties keep you covered if the direction ever changes.
It works in both axes
Auto margins operate in both directions, provided there is room to push. In one of the demos, it isn't alignment moving the menu down — it's an auto margin doing the work.



