Alignment keywords tell a CSS Flexbox container where to place its items. The center value gathers them in the middle instead of at the start or end. section 12.2
Choose the property that matches the direction you want to control:
- Use justify-content to arrange items along the main axis. section 12.2
- Use align-items to arrange items along the cross axis. section 12.2
- Set the value to center when the items belong in the middle of that axis. section 12.2
Center a row of items
container { display: flex; justify-content: center; } This places the flex items in the middle along the container's main axis. To center them along the cross axis too, add align-items: center.
