Design comparison
Solution retrospective
Is there a better way to make the QR code in the middle of page instead of using position?
Community feedback
- @HassiaiPosted almost 2 years ago
Replace <div class="QR-Code"> with the main tag, <h3> with <h1> to fix the accessibility issues. click here for more on web-accessibility and semantic html
To center .qr-code on the page using flexbox or grid instead of position: absolute, add min-height:100vh; display: flex; align-items: center: justify-content: center; or min-height:100vh; display: grid place-items: center to the body.
To center .qr-code on the page using flexbox: body{ min-height: 100vh; display: flex; align-items: center; justify-content: center; }
To center .qr-code on the page using grid: body{ min-height: 100vh; display: grid; place-items: center; }
For a responsive content which wont require a media for this challenge, replace the width in .qr-code to with max-width and increase its value for it to be equivalent to the width of the design.
max-width: 320px padding:15px
Give .text a margin value for all the sides, text-align: center and a font-size of 15px which is 0.9375rem, this will be the font-size of both p and h1. give p a margin-top value for the space between the text.
Use relative units like rem or em as unit for the padding, margin, width values and preferably rem for the font-size values, instead of using px which is an absolute unit. For more on CSS units Click here
Hope am helpful.
Well done for completing this challenge. HAPPY CODING
Marked as helpful0 - @MelvinAguilarPosted almost 2 years ago
Hello π. Congratulation on successfully completing your first challenge π ! !
I have some recommendations regarding your code that I believe will be of great interest to you.
HTML π·οΈ:
- Wrap the page's whole main content in the
<main>
tag.
- Always avoid skipping heading levels; Starting with <h1> and working your way down the heading levels (<h2>, <h3>, etc.) helps ensure that your document has a clear and consistent hierarchy. Source π
- Since this component involves scanning the QR code, the image is not a decoration, so it must have an
alt
attribute. Thealt
attribute should explain its purpose. e.g.QR code to frontendmentor.io
CSS π¨:
- Instead of using pixels in font-size, use relative units like
em
orrem
. The font-size in absolute units like pixels does not scale with the user's browser settings. Resource π.
-
Avoid using
position: absolute
to center an element as it may result in overflow on some screen sizes. Instead, utilize the flexbox or grid layout for centering. Get more insights on centering in CSS here here π.screenshot-imgur (landscape mode)πΈ.
- Using flexbox layout:
body { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; align-items: center; }
- Using grid layout:
body { min-height: 100vh; display: grid; place-content: center; }
I hope you find it useful! π Above all, the solution you submitted is great!
Happy coding!
Marked as helpful0 - Wrap the page's whole main content in the
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