CSS: justify-items (flex, grid)
(ai answer)
The justify-items CSS property defines the default alignment for all items within a grid or flex container along the inline (row) axis. It effectively sets the default justify-self value for every child element, unless that child overrides it individually.
This property is primarily used in CSS Grid layouts, where it controls horizontal positioning. In Flexbox, justify-items is generally ignored, as alignment is handled by justify-content (for the main axis) and align-items (for the cross axis).
Key values include:
- stretch: The default; items stretch to fill the grid cell width.
- center: Items are centered within their cells.
- start / end: Items align to the beginning or end of their cells.
- baseline: Items align based on their text baseline.
Unlike justify-content, which aligns the entire group of items within the container (controlling spacing between items), justify-items aligns each item individually within its own grid area.