Design comparison
Solution retrospective
I had a hard time getting the vertical margin aligned, I used margin for the spacing
Community feedback
- @ahmedhanyhPosted almost 2 years ago
Hey Seymmon!
margin: auto;
ormargin: 0 auto;
centers the element (or distributes available space) horizontally only and not vertically.You can center the container vertically (and horizontally) on the page using flexbox by adding some style declarations to the body, as in this code snippet:
body { ... min-height: 100vh; display: flex; justify-content: center; align-items: center; }
You can get rid of the margins now.
It's better to use a layout method like flexbox or grid instead of relying on margins to layout/space the content.
Resources to learn flexbox:
- This is a great resource to learn about flexbox, it contains all you need to know about it.
- A shorter flexbox lesson
I hope the review was helpful! I wish you the best with your future challenges!
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