Whereas align-items and align-self align items on the block axis, justify-items and justify-self aline items on the inline axis. The values you can choose from are similar to the normal, stretch, <self-position> and <baseline-position> values of the align-self property, along with left and right. Values include:
normal start end left right center stretch baseline first baseline last baseline -
auto (justify-self only)
You can see the same example as used for align-items, below. This time, we are applying the justify-self property.
Once again, the default is stretch other than for items with an intrinsic aspect ratio. This means that grid items will cover their grid area by default, unless you change the alignment. In this example, the first item demonstrates the default stretch alignment value:
.wrapper {
display: grid;
grid-template-columns: repeat(8, 1fr);
gap: 10px;
grid-auto-rows: 100px;
grid-template-areas:
"a a a a b b b b"
"a a a a b b b b"
"c c c c d d d d"
"c c c c d d d d";
}
.item1 {
grid-area: a;
}
.item2 {
grid-area: b;
justify-self: start;
}
.item3 {
grid-area: c;
justify-self: end;
}
.item4 {
grid-area: d;
justify-self: center;
}
<div class="wrapper">
<div class="item1">Item 1</div>
<div class="item2">Item 2</div>
<div class="item3">Item 3</div>
<div class="item4">Item 4</div>
</div>
As with align-self and align-items, you can apply justify-items to the grid container to set a justify-self value for all the grid items within the container.
Note: The justify-self and justify-items properties are not implemented in flexbox. This is due to the one-dimensional nature of flexbox, and that there may be multiple items along the axis, making it impossible to justify a single item. To align items along the main, inline axis in flexbox you use the justify-content property.