DEV Community

loading...
Cover image for 👋 Just a single CSS line for a perfect center layout

👋 Just a single CSS line for a perfect center layout

hunzaboy profile image Aslam Shah Updated on ・1 min read

place-items is a shorthand property for align-items and justify-items and can be used to perfectly center elements.

  display: grid;
  place-items: center;

Browser Support
MDN Docs

Live in Action:

Discussion

pic
Editor guide