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

Pure CSS with flexbox

pure-css
Jun Wei•200
@junwei-wong
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?
  • Using pure CSS, as I've been too reliant on component libraries
What challenges did you encounter, and how did you overcome them?
  • Importing fonts, just read the docs or W3Schools
What specific areas of your project would you like help with?
  • Anyway to do this in pure CSS without flexbox?
Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • P
    Rupali•890
    @rupali317
    Posted 11 months ago

    Hi @junwei-wong

    Congratulations on completing your first challenge. I have the following feedback for your code (in terms of enhancing the accessibility and semantics of the HTML):

    • You should always include a CSS reset for your projects. Different browsers may have different default stylings for UI elements. In order to make the CSS stylings consistent across all browsers , you should reset the CSS. Please refer to the following blog on CSS reset
    • For font size you should always use the rem unit instead of pixel. Pixel is not good for scalability and thus it will lead to poor accessibility. For instance, I am a user who relies on large font. So I will go to my browser settings to alter the font settings to a larger one. I will expect that the font in your qr code site to scale accordingly. But since you have used pixels, the font will remain the same and it will not scale to a larger one.
    • Your HTML structure in relation to the <main> tag is currently as follows:
    <main>
      <img>
      <div>
        <label></label>
        <label></label>
      </div>
    </main>
    

    Semantic HTML is preferable since it enhances the accessibility of your page and it leads to better SEO. Your code can be more semantic as follows:

    <main>
      <img>
        <h1></h1>
        <p></p>
    </main>
    

    A heading is represented as <h1>, <h2>, <h3>, <h4>, <h5>, <h6> A paragraph is represented as <p>. They are not appropriate as <label>

    • In your CSS, you have created CSS variables like --slate-300, --slate-500 etc. You can also extend using CSS variables for other properties like colors, font size, font weight etc so that you can reuse them and maintain the changes easily. For example, if the color scheme changes from blue to green, rather than having to change in various places, you just change the value of the CSS variable. For example:
    :root {
    
        /* Colors */
        --background-color: hsl(212, 45%, 89%);
        --card-color: hsl(0, 0%, 100%);
        --link-color: hsl(228, 45%, 44%);
        --main-text-color: hsl(218,44%,22%);
        --sub-text-color: hsl(220, 15%, 55%);
    
        /* Typography */
        --font-size-main: 1.375rem; /* 22px */
        --font-size-sub: 0.9375rem; /* 15px */
        --font-size-footer: 0.8125rem; /* 13px */
        --font-weight-bold: 700;
        --font-weight-regular: 400;
        --line-height-normal: 1.2;  /* Normal */
    
        /* Spacing */
        --space-none: 0;
        --space-base: 1rem; /* 16px */
        --space-m: 1.5rem; /* 24px */
        --space-l: 2.5rem; /* 40px */ 
    
        /* Border radius */
        --card-border-radius: 20px;  
        --img-border-radius: 10px;
    
        /* Box shadow */
        --card-box-shadow: 0px 25px 25px 0px rgba(0, 0, 0, 0.05);
    
    }
    

    Let me know if the above suggestions help.

    Marked as helpful
  • Lance•1,580
    @LanceOS
    Posted 11 months ago

    Good work!

    While you do need flexbox to center the card on the page you can do this with less flexbox by using no div containers! You can just have the image and the text in the card and use text-align: center to center everything in the middle of the card!

    Keep up the good work!

    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

Oops! 😬

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

Log in with GitHub