Skip to main content

Command Palette

Search for a command to run...

This one line CSS can center object easily : Putting end to your Google search

Updated
•2 min read•View as Markdown
This one line CSS can center object easily : Putting end to your Google search
R

19, Hustler.

It's hard to center thing in CSS. Most of the newbie web dev students face problem and often search every time when on any project. Here is the last and final solution to it. That is centering the object with just one line of CSS code.


The place-items property.
->The place-items property in CSS is shorthand for the align-items and justify-items properties, combining them into a single declaration. These properties have gained use with the introduction of Flexbox and Grid layouts

First, make sure to set the display property to grid and then, set the place-items property to center.

div {
   display: grid;
   place-items: center;
}

Ta Da DONE✨🎉🎉🎊 !!!

Thanks For Reading. I mostly do my project using this only. I hope you will find this helpful as i did. Sorry if it doesn't work with you.(it will work chill ✨🎉)

K

And that's two lines... 😂 But thanks this is something new!

1
R
Rahul6y ago

😑😑 😂 Glad you liked.

More from this blog

R

RAHULISM - FrontEnd Web Developer

232 posts

18, Hustler.