Three action chips move from normal document flow into a centered flex row with controlled alignment.

Program

Flexbox lays children along one axis. Justify-content works along the main axis; align-items works across it.

The container stays fixed; alignment changes where the child boxes sit inside it.Flex alignmentPinned state: display:flex; justify-content:center; align-items:centerflex containermain axis: justify-content moves the rowcross axisgap: 18px between neighboring itemsThe container stays fixed; alignment changes where the child boxes sit inside it.SavePreviewPublish
Figure: Flexbox main and cross axes. Model source: books/css/03flex_grid_layout/flex_alignment/diagrams/flex_alignment.semantic.json.
flex_alignment.html
Visuals: captured from real browser rendering
<style>
.toolbar { display: flex; }
.toolbar { gap: 12px; }
.toolbar { justify-content: center; }
.toolbar { align-items: center; min-height: 110px; background: #eef2ff; }
</style>

<nav class="toolbar">
  <button>Back</button>
  <button>Preview</button>
  <button>Publish</button>
</nav>
  1. Turn the toolbar into a flex container.

    The buttons line up horizontally.
    Flex items share a single row by default.
  2. Add equal space between flex items.

    The buttons separate evenly.
    Gap is simpler than adding margins to each button.
  3. Center items on the main axis.

    The button group moves to the center.
    Justify-content distributes free space along the flex direction.
  4. Center items across the cross axis.

    The toolbar gets taller and the buttons sit vertically centered.
    Align-items controls the cross-axis placement.
main axis The main axis follows the flex-direction.
cross axis The cross axis runs perpendicular to the main axis.