Design comparison
SolutionDesign
Solution retrospective
What's the best way to place a div in the center of a page, can you do it without using absolute positioning?
I got my solution from stackoverflow (https://stackoverflow.com/questions/356809/best-way-to-center-a-div-on-a-page-vertically-and-horizontally)
Community feedback
- @0-BSCodePosted over 2 years ago
Awesome work! With regards to your question, another way you could center the card in the page is giving your
html
element a display ofgrid and setting
align-items: center`. Although, the method you mentioned is also something I use regularly. Cheers!Marked as helpful0 - @MaikolrmPosted over 2 years ago
Hi! this is one of the most simple ways to do it:
/* main container */ .container { min-height: 100vh; display: flex } /* inner container */ .container__child { margin: auto }
And that's it... I hope this can help :)
Marked as helpful0
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