Design comparison
Solution retrospective
My solution to QR-code-component challenge. Please give a review
Community feedback
- @correlucasPosted about 2 years ago
👾Hello Kalhara, congratulations for your first solution! 👋 Welcome to the Frontend Mentor Coding Community!
👏 Great start and great first solution! You’ve done really good work here putting everything together, I’ve some suggestions you can consider applying to your code:
The approach you've used to center this card vertically is not the best way, because using margins you don't have much control over the component when it scales. My suggestions is that you do this alignment with
flexbox
using the body as a reference for the container.The first thing you need to do is to remove the margins used to align it, then apply
min-height: 100vh
to the body to make the child (the card/container) align to its size that now will be displaying 100% of the viewport height and then give its alignment withdisplay: flex
andalign-items: center
/justify-items: center
.Here's your code fixed:
REMOVE THE MARGIN:
.card { /* margin: 20rem auto; */ background: var(--clr--white); padding: 1.2rem; border-radius: var(--radius); max-width: 360px; }
ADD MIN-HEIGHT AND FLEXBOX:
body { min-height: 100vh; font-family: var(--ff-primary); background: var(--clr--grey); font-size: 15px; display: flex; align-items: center; justify-content: center; }
✌️ I hope this helps you and happy coding!
Marked as helpful1@ImpodaysPosted about 2 years ago@correlucas thank you so much. It really helps me
0 - @NiklausRupailPosted about 2 years ago
create a div with class container or use body tag, but you need to center that div body { height: 100vh; } and then .card { display: flex; justify-content: center; align-items: center; }
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