Design comparison
SolutionDesign
Solution retrospective
Is this the best way to center a div?
Community feedback
- @bccpadgePosted about 1 year ago
Hello @arnoldd98. Congratulations on completing this challenge!!!π
When I build projects, I use CSS Grid on the
body
to center content on the webpage.body{ display:grid; place-content:center; min-height: 100vh; }
- I suggest you stick to classes rather than Ids when styling elements in CSS. Ids are used for JavaScript.
More infoπ:
#qr-code { max-width: 100%; max-height: 100%; /*Remove this style its unnecessary */ display:block; /*Add this style and removes all the white space*/ border-radius: 15px; }
Hope this helps you
Marked as helpful2 - @chungvuiloongPosted about 1 year ago
For my projects,
Firstly I create a div, this the the container for contents. Then I add the classes flex, flex-columns, then justify-center as css. This usually does the centering for me for me.
Let me know if it does it for you too
1
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