Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted about 1 month ago

Qr code component

accessibility, cube-css, bem
Fernanda Nogueira•20
@Fernanda-NogueiraDA
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?

What I'm proud of: Pixel-perfect execution – Matched the design exactly with proper spacing, alignment, and responsive behavior. Accessibility focus – Used semantic HTML and proper alt text for the QR image. Clean code – Organized CSS with clear class names and logical structure.

What I'd improve next time: CSS variables – Replace hardcoded values with custom properties for easier maintenance. Performance check – Audit bundle size and optimize assets (though simple here, good practice). Enhanced interaction – Add subtle hover effects or focus states for better UX. Cross-browser testing – Verify rendering consistency beyond Chrome/Edge.

Key takeaway: This project solidified my layout skills, and I’m now eager to implement more scalable CSS approaches in future challenges.

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

Challenges Faced & Solutions:

Responsive Sizing

Challenge: Keeping the card proportionally sized on very small/large screens.

Fix: Used max-width with relative units (% + rem) and tested on Chrome DevTools’ device simulator.

Center Alignment

Challenge: Vertically centering the card without flex/Grid (for learning purposes).

Fix: Applied margin: auto with positioned layout as a fallback.

Color Matching

Challenge: Design’s subtle hsl() values looked different on my monitor.

Fix: Extracted exact colors using Figma’s eyedropper tool.

GitHub Pages Setup

Challenge: Initial deploy failed due to repo naming.

Fix: Renamed repo to username.github.io (required for root-level projects).

Lessons Learned:

Always test early on real mobile devices.

Double-check GitHub’s docs for deployment quirks.

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

Areas I'd like help with:

Code Review:

Is my HTML semantic enough? (e.g., did I overuse <div>?)

Could my CSS be more efficient? (e.g., reducing redundancy)

Best Practices:

Better way to handle the responsive layout? (Flexbox vs. Grid)

Accessibility checks beyond alt text.

Advanced Tips:

How to make the QR code interactive? (e.g., click animation)

Git strategy for tiny projects (branching needed?).

(Specific questions = better feedback!)

Example focused ask: “Is margin: 0 auto the cleanest way to center this card, or would Flexbox be more maintainable?”

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Asilcan Toper•2,960
    @KapteynUniverse
    Posted about 1 month ago

    Hey Fernanda, nice job.

    Is my HTML semantic enough? (e.g., did I overuse <div>?)

    I didn't see more than 1 div. It is ok. Think divs as layout containers. I recommend you to check landmarks and every element on MDN site.

    Maybe you can use article for the container. But wrap qr code container with a main. Every page needs 1 main.

    Alt texts should be descriptive, unless the img is decorative. So in this case something like "QR code leading to frontendmentor.io" might be better.

    Break rules <br> are bad for accessibility, i am not sure if there is a usage for br besides poetry or address. If you want to make the text exactly like the design, you can give apply padding or max-width.

    Could my CSS be more efficient? (e.g., reducing redundancy)

    Instead of height: 100vh; use min-height: 100vh; on the body, so it can grow if it needs to.

    Most of the times, you don't need to set height for the elements. For example, you can use

    .qr-code {
        /* height: 270px; */
        /* width: 270px; */
        max-width: 100%;
        display: block;
        border-radius: 10px;
    }
    

    position: relative; on the container seems unnecessary.

    I recommend you to use a modern css reset for every project. You can check Andy Bell's reset too.

    Better way to handle the responsive layout? (Flexbox vs. Grid)

    I don't know if you start with desktop or mobile layout, since this is a small component but for future projects starting with mobile is always easier.

    Chosing between flex or grid depends. It is user preference. Like bento grid challenge, you can make it with flex but it is better to use grid.

    It is always better to use max-width and never set font-size as px like Marzia said.

    Sometimes using clamp() function might be helpful.

    “Is margin: 0 auto the cleanest way to center this card, or would Flexbox be more maintainable?”

    Depends. I use margin-inline: auto; if i just want to center the element horizontaly. To center everything inside the body, flex or grid. Depending on the design, flex or grid again.

    How to make the QR code interactive? (e.g., click animation)

    You can put img into an anchor element and use :hover and :focus pseudo classes.

    You can also use click listener with js or :focus + tabindex with css and html but i won't recommend adding interactibility on a non interactable element.

  • Marzia Jalili•8,750
    @MarziaJalili
    Posted about 1 month ago

    Yo, props to you for discovering this incredible spot! 🎉🥳🎉 — this community is gold! 😎

    🌟 A quick win for responsiveness?

    ✅ Using pixels for font size is not a good idea because it doesn’t adjust well on different screen sizes or when users zoom in.

    ✅ It's better to use units like em or rem so the text can resize more easily and stay readable.

    ✅ Here you go with an example:

    p {
      /* Instead of this...*/
      font-size: 16px;
    
      /* Try this...*/
      font-size: 1rem;
    }
    

    So you could take that num in pixels and divide it by 16 to get the rem value, using calculator of course. 😅

    Well played overall — keep being awesome! 😎🔥🥇

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

How does the accessibility report work?

When a solution is submitted, we use axe-core to run an automated audit of your code.

This picks out common accessibility issues like not using semantic HTML and not having proper heading hierarchies, among others.

This automated audit is fairly surface level, so we encourage to you review the project and code in more detail with accessibility best practices in mind.

How does the CSS report work?

When a solution is submitted, we use stylelint to run an automated check on the CSS code.

We've added some of our own linting rules based on recommended best practices. These rules are prefixed with frontend-mentor/ which you'll see at the top of each issue in the report.

The report will audit all CSS, SCSS and Less files in your repository.

How does the HTML validation report work?

When a solution is submitted, we use html-validate to run an automated check on the HTML code.

The report picks out common HTML issues such as not using headings within section elements and incorrect nesting of elements, among others.

Note that the report can pick up “invalid” attributes, which some frameworks automatically add to the HTML. These attributes are crucial for how the frameworks function, although they’re technically not valid HTML. As such, some projects can show up with many HTML validation errors, which are benign and are a necessary part of the framework.

How does the JavaScript validation report work?

When a solution is submitted, we use eslint to run an automated check on the JavaScript code.

The report picks out common JavaScript issues such as not using semicolons and using var instead of let or const, among others.

The report will audit all JS and JSX files in your repository. We currently do not support Typescript or other frontend frameworks.

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