Design comparison
Solution retrospective
Hi everyone,
I just finished the single-price-grid-component challenge. There are "things" happening when in desktop design. The component is not centered in the screen but the margin is set to auto. Does anyone see the problem?
Thanks, Happy coding!!
Talasa
Community feedback
- @amalkarimPosted almost 2 years ago
Hi Talasa, congratulations for completing the challenge!
I think the problem lies in this code:
body { width: 375px; max-width: 400px; margin: auto; }
The browser will assume that
body
's width is always 375px (smallerwidth
overridesmax-width
), therefore it will calculate the center position based on that number. Removewidth: 375px;
andmax-width: 400px;
to solve the problem. Or, just remove them all, becausemargin: auto;
here doesn't do anything.To position the
<div class="container">
in the middle of the page, instead of usingmargin: auto;
, I suggest better solution usingflex
. Like this:body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
Hope this helps. Let me know if there's still something that needs to be addressed.
Happy coding!
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