coding180 icon
Coding180
CSS Grid: justify-items, align-items, place-items attribute

CSS Grid: justify-items, align-items, place-items attribute

Home > Tutorials > CSS > CSS Grid Layout


justify-items property sets the horizontal position of the cell content (left center right), and the align-items property sets the vertical position of the cell content (top center bottom).

.container {
  justify-items: start | end | center | stretch;
  align-items: start | end | center | stretch;
}

These two properties are written in exactly the same way, and both can take the following values.

  • start: Aligns to the starting edge (left) of the cell.
  • end: Aligns to the end edge (right) of the cell.
  • center: The cell is centered inside.
  • stretch: Stretch to fill the entire width of the cell (default value).
.container {
  justify-items: start;
}

The above code indicates that the content of the cell is left-aligned, and the effect is as shown in the figure below.

css grid justify item start coding180

.container {
  align-items: start;
}

The above code indicates that the content header of the cell is aligned, and the effect is as shown in the figure below.

css grid align item start coding180

place-items property is a combined shorthand for align-items property and attribute. justify-items

place-items: <align-items> <justify-items>;

Below is an example.

place-items: start end;

If the second value is omitted, the browser considers it equal to the first value.


user

Robort Gabriel

Lagos, Nigeria

Freelance Web Developer, Native Android Developer, and Coding Tutor.

Skills
  • UI / UX
  • JavaScript
  • Python
  • PHP
  • Kotlin
  • Java
  • Bootrap
  • Android
  • Laravel