Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted over 2 years ago

QR Code Component Using CSS Flexbox

Toshihiko S. Tani•160
@toshihikotani
A solution to the QR code component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


May I if there's another technique to center the content without using margin or padding?

Thank you

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Hassia Issah•50,390
    @Hassiai
    Posted over 2 years ago

    specify the following the body: body{ display: flex; justify-content: center; align-items: center; min-height: 100vh } or body{ min-height: 100vh display: grid; place-items: center;} this should help you with that. There is no need for wrapper div in the html Put the text content in a div and give it a class. In the css file give the class of the text content a padding top and bottom value. Give the img a max-width: 100% instead of resizing it . Use rem or em as unit for you padding and margin values Hope am helpful. Happy coding.

    Marked as helpful
  • tan•640
    @tan911
    Posted over 2 years ago

    Hello @toshihikotani, maybe this will help and improve your code:

    • Try to wrap your div element with "main" element for accessibility purposes and It's best practices that your page contain a main element.
    • use "h1" instead of "h2"
    • your concern about centering a div content, try to apply flexbox in you body element

    Hope it helps, Thanks.

    Marked as helpful
  • Cats-n-coffee•670
    @Cats-n-coffee
    Posted over 2 years ago

    Hi Toshihiko!

    Nice job! You're almost there centering your card. Since you already have the correct flex properties on #wrapper, all you need to do is make this same element take the full width of the screen. You might want to set min-width on your html and body elements as well. I would do 100vw since this card is expected to take the full screen, and your wrapper width: 100%.

    Hope this helps!

    Marked as helpful
  • PadseFIAE•70
    @PadseFIAE
    Posted over 2 years ago

    Hello Toshihiko, to center the content u could use Display Flex like this:

    body { display:flex; justify-content:center; align-items:center; height:100vh; }

    than the content should be centered :)

    Nice solution by the way. It looks close to the original.

    greetz Padse

    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

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