Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

QR Code component using HTML CSS

Djacson Stvilβ€’ 220

@djacsons

Desktop design screenshot for the QR code component coding challenge

This is a solution for...

  • HTML
  • CSS
1newbie
View challenge

Design comparison


SolutionDesign

Community feedback

Hassia Issahβ€’ 50,670

@Hassiai

Posted

Replace <div id="mainDiv"> with the main tag, <p id="p1"> with <h1> to fix the accessibility issues. click here for more on web-accessibility and semantic html

To center #mainDiv on the page using flexbox or grid instead of a margin, 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  #mainDiv on the page using flexbox:
body{
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
To center #mainDiv on the page using grid:
body{
min-height: 100vh;
display: grid;
place-items: center;
}

For a responsive content replace the width in #mainDiv with max-width, increase the width for it to be equivalent to the width of the design. max-width:320px.

Replace the height in #mainDiv with a padding value fo r all the sides, this will prevent the content from overflowing on smaller screens and its a responsive replacement. padding: 16px

Give the section 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.

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 helpful

0

@MelvinAguilar

Posted

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.
  • The text Improve Your Front-End Skills by Building Projects is considered a heading element (h1).
  • You should not use inline-CSS because it is not a good practice. Instead, you should use an external stylesheet to style your page. By doing this, you will be able to have a better organization of your code and will be able to understand it better.
  • For specificity reasons you should work with classes instead of ids because they are more reusable. You can use ids to work with JavaScript, but you should use classes to style your elements. You can read more about this here πŸ“˜. Alt text πŸ“·:
  • The alt attribute should explain the purpose of the image. Uppon scanning the QR code, the user will be redirected to the frontendmentor.io website, so a better alt attribute would be QR code to frontendmentor.io

    If you want to learn more about the alt attribute, you can read this article. πŸ“˜.

CSS 🎨:

  • Use more descriptive class names to improve readability of front-end code. You can learn BEM naming convention to improve your class names.
  • Instead of using pixels in font-size, use relative units like em or rem. The font-size in absolute units like pixels does not scale with the user's browser settings. Resource πŸ“˜.
  • To center the component in the page, you should use Flexbox or Grid layout. You can read more about centering in CSS here πŸ“˜.

I hope you find it useful! πŸ˜„ Above all, the solution you submitted is great!

Happy coding!

Marked as helpful

0

Please log in to post a comment

Log in with GitHub
Discord logo

Join 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