Design comparison
Solution retrospective
I wasn't sure if we were supposed to make it center vertically or not and I couldn't find a way to make it center both vertically and horizontally, if anyone has a suggestion for that it would be appreciated. Thanks.
Community feedback
- @mark-pherzPosted over 1 year ago
Hi Yoshi! Congratulations with your first challenge.
Try to replace your
body
and.main
with this:body { background-color: hsl(219, 39%, 84%); display: flex; justify-content: center; align-items: center; min-height: 100vh; } .main { border-radius: var(--BORDER-RADIUS); max-width: 355px; background-color: hsl(0, 0%, 100%); }
I suggest you to dive into
flex
andgrid
in CSS. These are the most powerful positioning and layout tools in CSS.I also suggest you visit this link: https://developer.mozilla.org/en-US/docs/Web/CSS/Layout_cookbook/Center_an_element
Hope it can help you, reach me out if you have more questions. Good luck!
Marked as helpful0@yoshi718Posted over 1 year agoThanks Mark, as a matter of fact I did just find that out for my second challenge.
0 - @Romedix1Posted over 1 year ago
If u want to center a div horizontally u can use few methods:
- margin: auto;
- justify-content: center; (flex)
- text-align: center;
,But if u want to center it vertically u can use:
- align-items: center; (flex)
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