justify-self CSS property is used in grid layouts to align individual grid items along the horizontal axis within their own grid cell. It allows you to control the horizontal alignment of a specific grid item within its grid cell.
justify-self property accepts various values to control the horizontal alignment of a grid item:
start: The grid item is aligned to the start of its grid cell.
end: The grid item is aligned to the end of its grid cell.
center: The grid item is centered horizontally within its grid cell.
stretch: The grid item is stretched to fill the entire width of its grid cell.
baseline: The grid item is aligned based on its baseline.
Here’s an example:
In this example, the
.grid-item class sets the horizontal alignment of the specific grid item to
center within its grid cell.
You can use other values like
baseline to achieve different horizontal alignments for individual grid items within the grid layout.
justify-self property is useful when you need to control the horizontal alignment of specific grid items within their grid cells, allowing for fine-grained control over the layout and positioning in grid layouts.