Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted about 3 years ago

QR Code Component - HTML and SASS with Flexbox

sass/scss
Bel Sahn•440
@BelumS
A solution to the QR code component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


This is my first solution to FrontEnd Mentor, and was fairly simple, with minor nitpicks.

Feedback is welcome for the following questions:

  • How were you able to center the card?
  • How were you able to match the paragraph text color?
  • What color and specs are the box-shadow?
  • Did I use too much CSS?
Code
Couldn’t fetch repository

Please log in to post a comment

Log in with GitHub

Community feedback

  • Vanza Setia•27,715
    @vanzasetia
    Posted about 3 years ago

    Hello, Bel Sahn! 👋

    It looks like @gerichilli has answered all your questions. I just want to add some things.

    • The role attribute can't receive random values. Also, you don't need to use role attributes in this case. I recommend using the semantic HTML whenever possible.
    • I also don't recommend changing the html or the :root font size. It can cause huge accessibility implications for those users with different font size or zoom requirements. I suggest reading this article by Josh Comeau where he tells about the problem of the 62.5% trick (and more!).
    • I highly recommend writing the styling using the mobile-first approach. So, instead of using max-width media query, you will use min-width media queries. It often leads to shorter and better performance code. Also, mobile users won't be required to process all of the desktop styles.

    I hope this helps!

    Marked as helpful
  • Mi Vu•380
    @gerichilli
    Posted about 3 years ago

    Hi Bel Sahn, Congratulations on completing the first challenge, nice to meet you.

    First of all, I would like to answer your questions

    *** I have center this card as follows

    • I wrapped the card into a div .wrapper. I set the min-height of the .wrapper to 100vh to have a page that has the length >= the screen's height. You also don't need to use role="body" for the body tag because it's not necessary. And you don't need to use role="main" for the section because it's incorrect. You can read about the section tag here Section - MDN docs
    <div class="wrapper">
      <section class="card">
      </section>
    </div>
    
    • Then I use display: flex, align-items and justify-content to make the card centered on main
    .wrapper {
       /* */
      min-height: 100vh;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 2rem;
    }
    
    • You can set the footer's position to absolute and put it at the bottom of the page so that it doesn't make the page height exceed 100vh
    • In .card you can remove margin: 20rem auto.
    • Now your card is in the center of the screen.

    *** You can find colors in style-guide.md, or if not, I usually use the EYE DROPPER extension to search for colors. Since the font is thin, I usually open the image in a separate tab, zoom in, and use the eye dropper to detect its color.

    *** Box shadow is

    box-shadow: 0px 25px 25px 0px rgba(0, 0, 0, 0.05)
    

    You can see the shadow is wide, blurred, the bottom of the card has shadow but the top is not. In such a case usually the y-offset and blur-radius will be large.

    *** I think you use enough css, but you should limit the use of roles in the html and if you do, read about it and be careful with it.

    *** Also we should not set the html font-size to 62.5%. It will be hard to combine your CSS with bootstrap because the html in bootstrap was 100%. You can read the explanations here. Never resize html/root font size down to 62.5%

    Have a nice day and happy coding!

    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

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