Skip to content
  • Learning paths
  • Challenges
  • Solutions
  • Articles
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted 11 months ago

Qr component using padding and border radius with a bit of font css

sass/scss, vite, vue, typescript
Ryan•30
@Ryoliveira
A solution to the QR code component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


What are you most proud of, and what would you do differently next time?

Getting this solution with little effort

What challenges did you encounter, and how did you overcome them?

Getting the image to stay within the container was a bit of a struggle for me. Learning that only max-height is needed for an image to adhere to its parents dimensions (given that the parent element also has a set height)

What specific areas of your project would you like help with?

Are there any properties that I should add to handle unexpected scenarios?

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Grace•32,130
    @grace-snow
    Posted 11 months ago

    I'm afraid this is missing the foundations of necessary html for the content.

    1. Every page must have a main landmark. This is only a single component challenge but you should still have a main container on the page, and your card component would then go inside it.
    2. Keep the html as simple as possible. The image does not need wrapping in an extra div.
    3. The image is the most important content on the page. It must have a proper alt description of what the image is (QR code) and where this code goes (to FrontendMentor.io). There are good posts about how and when to write alt text on images in the resources channel on discord.
    4. Use meaningful elements! This is so important I can't stress it enough as it's the biggest single thing your solutions are missing at the moment. This card should have a heading element and a paragraph, not divs wrapping text. Text should never be in divs or spans alone as they are meaningless elements for layout only.
    5. Get into the habit of including a full modern css reset at the start of the styles in every project. Andy Bell or Josh Comeau both have good ones you can look up and use.
    6. The card must not have a width or height. It should only have a max width in rem. That limits its width but allows it to shrink narrower when it needs to (like on smaller screens or when zoomed). The value should be in rem so the layout scales correctly for all users including those who have a different text size setting. You never want to limit the height of elements that contain text as you can never guarantee what height is needed —that is the browsers job to decide the height based of the content.
    7. The image shouldn't be wrapped in a div with an explicit size and the image must not have a height. It should be max-width 100% (not height) but this would be part of any standard css reset anyway. So if the css reset was included you would only need to give this img a border radius. For a performance boost you could give the img an aspect ratio of 1 as well, as it's a square image.
    8. The padding should be in the card component, not on a div wrapping the img.
    9. Font size must never be in px. Use rem. The font size in the style guide should be converted to rem then used on the body. That gives you the correct paragraph size.
    10. Make sure you understand the difference between padding and margin. I would expect to see margin to create vertical space between elements within the card not padding.
    Marked as helpful

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
Frontend Mentor logo

Stay up to datewith new challenges, featured solutions, selected articles, and our latest news

Frontend Mentor

  • Unlock Pro
  • Contact us
  • FAQs
  • Become a partner

Explore

  • Learning paths
  • Challenges
  • Solutions
  • Articles

Community

  • Discord
  • Guidelines

For companies

  • Hire developers
  • Train developers
© Frontend Mentor 2019 - 2025
  • Terms
  • Cookie Policy
  • Privacy Policy
  • License

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Frontend Mentor for Teams

Frontend Mentor for Teams helps companies and schools onboard and train developers through project-based learning. Our industry-standard projects give developers hands-on experience tackling real coding problems, helping them master their craft.

If you work in a company or are a student in a coding school, feel free to share Frontend Mentor for Teams with your manager or instructor, as they may use it to help with your coding education.

Learn more

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub