QR Component Desktop version using HTML and CSS
Design comparison
Solution retrospective
What are the best practices for writing clean CSS code? What is the best way to centre a div?
Community feedback
- @dorian-edwardsPosted over 2 years ago
If a div has a width < 100% or < 100vw you can use "margin: 0 auto" to center it as well. the 0 sets the margin along the y axis, top and bottom, to 0, and auto will put enough margin on either side of your div along the x axis to set it in the middle of the screen.
The div element is block level by default so this works, if you override the display of your div and make it inline or inline-block, this will no longer work.
1 - @CreatorLZPosted over 2 years ago
Hi. Nice work!. To center a div I generally use this syntax; display:flex; align-items:center justify-content: center
1 - @DoriseneOPosted over 2 years ago
this is nice.i think you should have increased your font-size a little.
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