Design comparison
Solution retrospective
Hi, is there any way to put the page at the center of the body without manually using margins? Justify-content and align-items seems to work but it doesn't affect the top of the page. Thanks. feedback are appreciated.
Community feedback
- @xSStephenPosted about 2 years ago
Hello Osauyi! Great solution for this challange!
Regarding your question, you can use the following code to center the parent container in the middle of the screen using flexbox.
display: flex; justify-content: center; align-items: center; min-height: 100vh;
Marked as helpful1 - @correlucasPosted about 2 years ago
👾Hi @Osauyi, congratulations on your solution!
From what I saw you’re on the right track. I’ve few suggestions for you that you can consider adding to your code:
1.Remove the
margin
and addmin-height: 100vh
to make sure the body size is the screen height ever:main { display: flex; justify-content: center; align-items: center; /* margin-top: 80px; */ } body { min-height: 100vh; background-color: hsl(212, 45%, 89%); font-family: 'Outfit', sans-serif; display: flex; justify-content: center; align-items: center; flex-direction: column; }
2.Clean your code by removing some unnecessary divs, most of the content can stand alone without a div. Use div only for blocks that need a special alignment or the content needs a special positioning.
3.Use relative units as
rem
orem
instead ofpx
to improve your performance by resizing fonts between different screens and devices. These units are better to make your website more accessible. REM does not just apply to font size, but to all sizes as well.Here's my solution for this challenge if you wants to see how I build it: https://www.frontendmentor.io/solutions/qr-code-component-vanilla-cs-js-darklight-mode-nS2aOYYsJR
✌️ I hope this helps you and happy coding!
Marked as helpful1
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