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 Solution

Samoina 220

@samoina

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

There is no need to give the body a height and padding value.

To center .main on the page using flexbox or grid instead of margin,

  • USING FLEXBOX: add min-height:100vh; display: flex; align-items: center: justify-content: center; to the body
body{
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
  • USING GRID: Add min-height:100vh; display: grid place-items: center to the body
body{
min-height: 100vh;
display: grid;
place-items: center;
}

Reduce the max-width of .main for it to be equivalent to the design. max-width: 320px which is 20rem/em Give the img a max-width of 100% and a border-radius value for a responsive image, the rest are not needed.

Give h1 and p the same font-size of 15px which is 0.9375rem, text-align: center,the same margin-left, margin-right and margin-top values. Give p a margin bottom value.

Hope am helpful.

Well done for completing this challenge. HAPPY CODING

Marked as helpful

1

Samoina 220

@samoina

Posted

@Hassiai thank you so much for this insightful feedback. Happy to include it in this and other future challenges I do :)

0

@0xabdulkhaliq

Posted

Hello there 👋. Congratulations on successfully completing the challenge! 🎉

  • I have other recommendations regarding your code that I believe will be of great interest to you.

HEADINGS ⚠️:

  • This solution has also generated accessibility error report due to lack of level-one heading <h1>
  • Every site must want at least one h1 element identifying and describing the main content of the page.
  • An h1 heading provides an important navigation point for users of assistive technologies, allowing them to easily find the main content of the page.
  • So we want to add a level-one heading to improve accessibility by reading aloud the heading by screen readers, you can achieve this by adding a sr-only class to hide it from visual users (it will be useful for visually impaired users)

CSS 🎨:

  • let me explain, How you can easily center the component for better layout.
  • We don't need to use margin and padding to center the component both horizontally & vertically. Because using margin or padding will not dynamical centers our component at all states
  • To properly center the component in the page, you should use Flexbox or Grid layout. You can read more about centering in CSS here 📚.
  • For this demonstration we use css Grid to center the component
body {
    min-height: 100vh;
    display: grid;
    place-items: center;
}
  • Now remove these styles for body and div, after removing you can able to see the changes
body {
  padding: 4rem 2rem 2rem 2rem;
}
.main {
   margin: 0 auto;
}

.

I hope you find this helpful 😄 Above all, the solution you submitted is great !

Happy coding!

Marked as helpful

0

Samoina 220

@samoina

Posted

@0xAbdulKhalid i really appreciate the feedback on how to add the h1 because I was wondering how to do it yet structure wise the page didn't appear to need one. An oversight on my part regarding the use of assistive technology. I will keep this in mind for current and future projects. Thanks :)

0
Ecem Gokdogan 9,380

@ecemgo

Posted

Some recommendations regarding your code that could be of interest to you.

In order to fix the accessibility issue:

  • Each main content needs to start with an h1 element. Your accessibility report states page should contain a level-one heading. So, you need to use a <h1> element in the <main> tag instead of using <h2>. You can replace your <h2 class="main__title">Improve your front-end skills by building projects</h2> element with the <h1 class="main__title">Improve your front-end skills by building projects</h1> element.

Hope I am 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