Design comparison
Solution retrospective
I found positioning the QR-CONTAINER at the center difficult. I resolved this by playing around with margin. I was also stuck on border radius for the image. The effect was only applying at the top. This was because I used padding bottom to create space between the image and the text instead of margin bottom.
Community feedback
- @danielmrz-devPosted 10 months ago
Hello @jefta-jose!
Your project looks great!
I noticed that you used
margin
to place the card in the middle of the page. Here's a very efficient way to center the card:- Apply this to the body (in order to work properly, you can't use position or margins):
body { min-height: 100vh; display: flex; justify-content: center; align-items: center; }
I hope it helps!
Other than that, great job!
0 - @solvmanPosted 10 months ago
🚀Great job! 🚀
I have a few suggestions to improve your code. Do not use all caps for your class names. Also, centering content vertically using hard-set margins makes your design not responsive to height changes. I would change up your container class like so:
.qr-container { background-color: white; border-radius: 20px; text-align: center; padding: 20px 20px 40px 20px; max-width: 300px; border: 1px solid #ccc; }
To center your container, you can use a couple of methods:
1. Flexbox:
body { margin: 0; padding: 0; font-family: 'Outfit', sans-serif; background-color: rgb(213, 225, 239); overflow: hidden; height: 100vh; display: flex; align-items: center; justify-content: center; }
2. Grid:
body { margin: 0; padding: 0; font-family: 'Outfit', sans-serif; background-color: rgb(213, 225, 239); overflow: hidden; height: 100vh; display: grid; place-content: center; }
I prefer the last method since it uses one less line of code. 😄
Congratulations🎉, and keep up the good work! 👍
0 - @Lolito-Lindsey-OfficialPosted 10 months ago
First off, amazing job with the QR code component! Regarding the centering of the QR-container, totally get it! This FreeCodeCamp article was of great help when I was working on the previous challenges. Hopefully it helps for future projects! Best of luck :)
https://www.freecodecamp.org/news/how-to-center-anything-with-css-align-a-div-text-and-more/
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