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

plain CSS

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

Just quick solution with flexbox.

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Brian Muniz Silveira•200
    @BrianMunizSilveira
    Posted 7 months ago

    Solution Retrospective: QR Code Component Challenge


    What Are You Most Proud Of, and What Would You Do Differently Next Time?

    You mentioned creating a quick solution with Flexbox, and that’s great! Flexbox is a powerful tool for creating aligned and centered layouts. This approach showcases efficiency and skill in applying essential CSS techniques to solve design challenges.

    Next time, you might want to explore adding responsive design techniques to ensure the component works well on devices with different screen sizes. This would be an excellent next step to continue improving your front-end skills.


    Suggestions for Improvement

    Here are some suggestions to enhance the quality of your solution and broaden your learning:

    1. Make the Component Responsive

    Your layout works well with a fixed size, but adding responsiveness can improve the experience across devices. Consider adjusting the width and height of the component to adapt to various screen sizes:

    @media (max-width: 480px) {
        .img-container {
            width: 90%; /* Adjusts width on smaller screens */
            padding: 20px; /* Adds more padding */
        }
    
        .qr-image {
            width: 100%; /* Makes the image flexible */
            margin-top: 10px; /* Adjusts margin */
        }
    
        .qr-image-title {
            font-size: 18px; /* Reduces title size */
        }
    
        .qr-image-description {
            font-size: 14px; /* Reduces description size */
        }
    }
    

    2. Improve HTML Semantics

    Using semantic tags in your HTML makes the code more accessible and descriptive. For example:

    • Instead of using <div class="img-container">, consider using a <section> with a descriptive class.

    • Add an alt attribute to the <img> tag to improve accessibility.

    Updated example:

    <section class="qr-card">
      <img class="qr-image" src="images/image-qr-code.png" alt="QR Code to visit Frontend Mentor">
      <h2 class="qr-image-title">Improve your front-end skills by building projects</h2>
      <p class="qr-image-description">Scan the QR code to visit Frontend Mentor and take your coding skills to the next level</p>
    </section>
    

    3. Add Interactive Details

    Small interactions can make the design more engaging. For example, a hover effect on the card or the image:

    .img-container:hover {
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
        transition: box-shadow 0.3s ease-in-out;
    }
    
    .qr-image:hover {
        transform: scale(1.05);
        transition: transform 0.2s ease-in-out;
    }
    

    4. Centralize and Reuse Styles with CSS Variables

    Adding variables for colors and spacing will make the code cleaner and easier to update. Example:

    :root {
        --background-color: rgb(213, 225, 239);
        --card-background: #fff;
        --border-radius: 10px;
        --font-size-title: 20px;
        --font-size-description: 15px;
    }
    
    body {
        background-color: var(--background-color);
    }
    
    .img-container {
        background-color: var(--card-background);
        border-radius: var(--border-radius);
    }
    
    .qr-image-title {
        font-size: var(--font-size-title);
    }
    
    .qr-image-description {
        font-size: var(--font-size-description);
    }
    

    5. Comment and Document Your Code

    Adding comments helps with collaboration and code maintenance:

    /* Main body styling */
    body {
        display: flex;
        justify-content: center;
        align-items: center;
        height: 100vh;
        margin: 0;
    }
    
    /* Container for the QR card */
    .img-container {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        background-color: var(--card-background);
        border-radius: var(--border-radius);
    }
    

    Summary Your quick solution with Flexbox is functional and well-structured! By focusing on responsiveness, semantics, interactivity, and code organization, you can create even more complete and polished components that are ready for larger projects.

    Keep exploring new techniques and challenges! 🚀😊

    Brian.

    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

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