Design comparison
Solution retrospective
Hi! I would appreciate it if you give me feedback on how I use flexbox in this project to center the QR card
Community feedback
- @MelvinAguilarPosted about 2 years ago
Hi @FatimaGR ๐, good job for completing this challenge and welcome to the Frontend Mentor Community! ๐
Here are some suggestions to improve your code:
To center the element:
- Use
min-height: 100vh
tobody
instead ofheight: 100%
so that it occupies the full height of the screen. - Add
justify-content: center
andalign-items: center
to body element, these properties will place the card in the center. - Remove
margin: 6% auto;
from thecontainer
selector.
More information:
- The Complete Guide to Centering in CSS
- A Complete Guide to Flexbox (CSS-Tricks)
- How TO - Center Elements Vertically (W3Schools) |
- CSS Layout - Horizontal & Vertical Align (W3Schools)
Try to fix the issues indicated by the report in this solution.
Update the image to make it a bit responsive:
img { width: 100%; object-fit: contain; border-radius: 11px; }
I hope those tips will help you.
Good Job and happy coding !
Marked as helpful2 - Use
- @Wonski312Posted about 2 years ago
Yes as above you can youse justify-content and align-items with flex to centre your box container on the body. Setting img size with px may couse problems with responivnes if you will still use it like that instead of width 100%. And all content could be set with flex direction column Paragraph with title class could have h1 so itโs more semantic and in challenge directions you have font size set to 15px so you could set it straight away in your body set up
Well done and good luck with your next projects
Marked as helpful1 - @correlucasPosted about 2 years ago
๐พHi Fatima, congratulations on your solution!๐ Welcome to the Frontend Mentor Coding Community!
Great solution and a great start! From what I saw youโre on the right track. Iโve few suggestions for you that you can consider adding to your code:
- Use
<main>
instead of a simple<div>
this way you improve the semantics and accessibility showing which is the main block of content on this page. Remember that every page should have a<main>
block and that<div>
doesn't have any semantic meaning. - Replace the
<h2>
containing the main title with<h1>
note that this title is the main heading for this page and every page needs one h1 to show which is the most important heading. Use the sequence h1 h2 h3 h4 h5 to show the hierarchy of your titles in the level of importance, never jump a level. - Add a margin of around
margin: 20px
to avoid the card touching the screen edges while it scales down.
Here's my solution for this challenge if you wants to see how I build it: https://www.frontendmentor.io/solutions/qr-code-component-vanilla-cs-js-darklight-mode-nS2aOYYsJR
โ๏ธ I hope this helps you and happy coding!
1 - Use
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