Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted 4 months ago

QR Code Component

Konrad•200
@ExtendoGH
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?

I am proud of the following aspects of my project:

— Utilizing CSS variables for color management, ensuring consistency and scalability.

— Exclusively using REM units for responsive typography and layout.

— Effectively positioning elements to achieve a clean and organized structure. — Faithfully replicating the original design with close attention to detail.

— Using only class selectors in CSS, resulting in a clean, consistent, and maintainable codebase.

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

I encountered a challenge with centering the box but resolved it by setting the height to 100vh.

Aside from that, all other elements were implemented smoothly.

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

I would appreciate feedback on the following areas of my project:

— Is my approach to centering elements using height: 100vh the most efficient, or are there better alternatives?

— Are there any improvements I could make to my use of CSS variables and class selectors to enhance maintainability or scalability?

— Does the code follow best practices for responsive design, especially with the exclusive use of REM units?

— Are there any areas where my positioning or layout could be optimized for better readability or accessibility?

Specific insights or suggestions on these aspects would be highly valuable.

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Aakash Verma•9,500
    @skyv26
    Posted 4 months ago

    Hi @ExtendoGH, 😊

    I reviewed your project, and I must say you've done a commendable job! Here's a detailed breakdown of your code, along with some suggestions to improve it even further.


    1. Simplifying CSS Spacing with Flexbox

    Your current approach to using margin-bottom repeatedly for spacing works but can become hard to maintain as the project scales. Instead, leveraging display: flex on the container with gap is a more scalable and efficient solution.

    An Example:
    Imagine you’re organizing books on a shelf. Instead of leaving varying gaps manually between each book, you could use dividers that maintain consistent spacing.

    Refactor Suggestion:

    /* Current Code */
    .qr-img {
        width: 100%;
        border-radius: 10px;
        margin-bottom: 2.4rem;
    }
    
    .qr-heading {
        color: var(--slate-900);
        font-size: 2.2rem;
        font-weight: bold;
        line-height: 120%;
        margin-bottom: 1.6rem;
    }
    
    /* Refactored Code */
    .qr-container {
        display: flex;
        flex-direction: column;
        gap: 1.6rem; /* Controls spacing between child elements */
        background-color: var(--white);
        border-radius: 20px;
        max-width: 32rem;
        padding: 1.6rem;
        filter: drop-shadow(0px 25px 25px rgba(0, 0, 0, 0.0477));
    }
    

    Benefits:

    • Reduced CSS redundancy.
    • Dynamically adjusts spacing if new content is added.
    • Cleaner and more maintainable code.

    2. Meaningful Comments in CSS

    While your current comments are organized, they could be more descriptive to help other developers understand the intent behind specific styles. Avoid shorthand like "OUTFIT BOLD: FZ: 22px" and opt for explanations.

    Why this matters:
    Think of a recipe. Instead of writing "use 1 tsp," specifying "use 1 tsp of salt to enhance flavor" makes it easier for someone following the instructions.

    Refactor Suggestion:

    /* Current Comment */
    --02--TYPOGRAPHY
    - OUTFIT BOLD: FZ: 22px, LH: 120%, LS: 0px
    
    /* Refactored Comment */
    -- Typography
    - Use Outfit Bold font for headings, ensuring readability with a font size of 22px, line height of 120%, and letter spacing of 0px.
    

    3. Optional but Handy: Avoiding Repetition in Styles

    Your solution to center cards with height: 100vh is excellent! While position-based centering (position: absolute; transform) works too, your method is simpler and easier to maintain. Great job! 👏

    Example of Position-Based Centering (not necessary here):

    .qr-container {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
    }
    

    But your approach is better for this use case—cleaner and beginner-friendly.


    Final Note

    You're off to a great start! Keep experimenting with semantic HTML, flexible layouts, and concise commenting to make your code even more robust and future-proof. 🚀

    Feel free to reach out for further discussions or feedback. Happy coding! 😊

    Marked as helpful
  • lion9•70
    @lion9
    Posted 4 months ago

    Well done!

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 1st-party linked stylesheets, and styles within <style> tags.

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.

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