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

QR-code-component Using HTML and CSS

Yu-An•70
@yuany2036
A solution to the QR code component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


While I was working on this challenge, I came across two issues that I couldn't solve:

  • When making the edges of the "container" (the one that housed the QR code and the text) rounded by using border-radius, I was unable to make it smooth; for some reason there are somewhat jagged edges
  • When zooming in on the browser, the top would become cut-off, and I would be unable to scroll to the top to view the content there

Please let me know if you know what is causing the problems, thanks!

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • mycrochip•460
    @mycrochip
    Posted about 3 years ago

    Hello Yu-An,

    I congratulate you on beginning your journey on Frontend mentor. You'll find so much value in this community.

    You've put forward a good solution to the project challenge.

    At first glance, I see you've added styles to your <html> element in your stylesheet. As a personal best practice, and I believe, with most developers as well, I do not add styles to my HTML. I prefer to put such styles in the <body> element and if I need an extra container, I'll just nest another <div> element within the 'body' to surround all the current child elements.

    The first issue was caused by setting

    html {
    display: flex;
    } 
    

    The flex container gives its children fluid dimensions when they are not set. So, the body has a width of less than 100% of the available screen.

    FIX: Replace the html selector with the body selector as follows:

    body {
    display: flex;
    flex-direction: column;
    justify-cotent: center;
    align-items: center;
    height: 100vh;
    width: 100%;
    }
    

    This should fix some layout issues. You'd still need to adjust your card for mobile view.

    With regards to the rounded edges being cut off, the culprit here is still the flex layout. The card container (main) is so fixed to the top of its parent which is the body.

    FIX: Make the card center on the page which will make it move away from the top. This is not centered currently even if you have a justify-content and align-items set to center because these attribute don't know the dimension of your element (i.e how tall or wide it is). So, you can either set a fixed width and height for the 'main' container (which i don't recommend due to overflow issues of child contents) or give a block margin to the container (or block padding to its parent), e.g:

    main {
    margin-top: 20%;
    margin-bottom: 20%;
    }
    
    /*OR*/
    
    main {
    margin-block: 20% 20%;
    }
    
    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