Design comparison
Solution retrospective
I defined the body of my document as a "flexbox" and used padding to center my qr-code. Was there an easier way to get my qr-code in the center? So yes, how? My images also disappear when I upload it live, what do I have to put in my code to avoid this?
Community feedback
- @BagataaPosted over 1 year ago
Hey, you can easily center your card with Flex. In the body element, you should give height:100vh body { display: flex; justify-content: center; align-items: center; height:100vh } And you must delete the padding from the body you don't need it. Tip: U don't need flex-direction: row, By default, the flex items are placed in the row direction. HAPPY CODING
Marked as helpful3@YannickMukengPosted over 1 year agoThank you for the feedback! Very helpful! :) @Bagataa
0 - @francescomerighi1202Posted over 1 year ago
To perfectly center an element within the page you can use flexbox or grid.
Unfortunately the code on GitHub is not visible but I understand that you used flexbox to center it horizontally, you can also use it to center it vertically, thanks to the property 'align-items: center'
Set a height of 100vh to the body, or the (parent) div that contains the card.
I hope I was helpful, anyway, if you need, you can check my solution ;)
Marked as helpful3@YannickMukengPosted over 1 year agoThank you very much for your comment! I corrected it! @francescomerighi1202
1@francescomerighi1202Posted over 1 year ago@YannickMukeng no problem, always glad to help
0 - @UdbhavDalmiaPosted over 1 year ago
You can add flex but you can also add margin right and left: auto; it would center it horizontally and make sure to do display: block; so it would be horizontally centered.
Upload the QR code image and the favicon in the GitHub repository then they will show.
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