Design comparison
Solution retrospective
I fall short on "Centering" the entire content from top and bottom.
I auto margin and make its position absolute and still nothing.
I keep guessing top pxs needed to be center it manually. isn't there a better way?
Community feedback
- @brodiewebdtPosted almost 3 years ago
To center all your content in the center of the page:
- It needs to be in one div.
- Put display: grid, align-items:center, justify-content:center, height: 100vh on the body tag. That will put your content in the center of the page.
Marked as helpful1 - @ShreykrPosted almost 3 years ago
I suggest you refer to the plenty of videos and resources out there.
The simplest way I find (without using grid) is to use flexbox, justify-content: center, and align-items: center, on the element wrapping all the child elements.
0@wella4lifePosted almost 3 years ago@Shreykr but grid doesn't center your entire content in the middle of the page.
I think the only thing coming close to being able to do that is translate. and it sometimes is a little weird when it comes to different margins
0@ShreykrPosted almost 3 years ago@wella4life
https://www.freecodecamp.org/news/how-to-center-objects-using-css/#:~:text=How%20to%20center%20a%20div%20horizontally%20%26%20vertically%20using%20CSS%20Grid
Do refer to this. Also, what David said in the other comment.
0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord