Design comparison
Solution retrospective
I'm starting to use relative measurement units so I'd like tips and advice.
Community feedback
- @0xabdulkhaliqPosted over 1 year ago
Hello there 👋. Congratulations on successfully completing the challenge! 🎉
- I have other recommendations regarding your code that I believe will be of great interest to you.
CSS 🎨:
- Looks like the component has been centered properly but you have used two
flex
layouts. So let me explain, How you can easily center the component without using twoflex
layouts
- We don't need to use two
flex
layouts to center the component both horizontally & vertically. Because using twoflex
layoutswill decrease performance (even its dropped by
.1%` that's a dev's prespective)
- You already using
Flexbox
for layout, but you didn't utilized it's full potential. Just add the following rules to properly center the component.
body { min-height: 100vh; }
- Now remove these styles, after removing you can able to see the changes
main { width: 100vh; height: 100vh; display: flex; justify-content: center; align-items: center; }
- You've reduced significant amount of code, Now your component has been properly centered in a efficient manner
.
I hope you find this helpful 😄 Above all, the solution you submitted is great !
Happy coding!
Marked as helpful1 - @DumtePosted over 1 year ago
The first thing here is to center the container both vertically and horizontally.
body { min-height:100vh; } main{ display: flex; place-items: center; }
In this case your container will find itself at the very center of the browser.
Note that I've replaced justify-content and align-items center with place-items: center; and it still does the same thing.
Marked as helpful0 - @HassiaiPosted over 1 year ago
Use relative units like rem or em as unit for the padding, margin, width values and preferably rem for the font-size values, instead of using px which is an absolute unit. For more on CSS units Click here and here
Hope am helpful.
Well done for completing this challenge. HAPPY CODING
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