Design comparison
Community feedback
- @correlucasPosted about 2 years ago
๐พHello @tossik8, Congratulations on completing this challenge!
One tip about alignment best practices:
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 suggestion is that you do this alignment with
flexbox
using the body as a reference for the container.Remove the margins
body main { background-color: hsl(0deg, 0%, 100%); width: 26.33vw; margin: 0 auto; /* margin-top: 8rem; */ border-radius: 20px; text-align: center; }
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
.If you're using the attribution you need to addflex-direction: column
to make the attribution stays under the QR Code component. See the code below:body { min-height: 100vh; margin: 0; font-family: "Red Hat Display", sans-serif; background: url(../images/pattern-background-desktop.svg) no-repeat; background-size: contain; background-color: hsl(225deg, 100%, 94%); display: flex; align-items: center; justify-content: center; flex-direction: column; }
โ๏ธ I hope this helps you and happy coding!
Marked as helpful0@tossik8Posted about 2 years agoHello @correlucas, Thank you for the advice, I've changed the code as you suggested. I haven't thought of this approach before and it is much much better. Thank you and 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