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

QR code component using CSS Flexbox

Aiden•20
@sorcerycss
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?

I'm extremely proud of making this my very first challange here, on Fronted Mentor. The QR code component is a great starter project and I really enjoyed it despite being a little bit lazy with refactoring my CSS. I'd definetely be more efficient with my styles next time and not overthink as much as I do.

What challenges did you encounter, and how did you overcome them?

I had trouble centering the component using flexbox. The way I approched this was by adding height: 100vh; to my generic .container. I haven't learn much about the viewport units yet, just have the basic idea of how it works, but it seemed to make it work for this challange.

What specific areas of your project would you like help with?

First of all, I'd love to hear experitise opinion regarding the CSS reset, more specifically box-sizing: border-box;. I noticed that it shrinks the component a little bit, so I decided to comment it out for now. Please advise!

This is my very first solution on this platform plus I have zero experience working with Figma, so I'd also love to find out if my min-width: 288px; and max-width: 288px; on generic .container have place to be as a workaround.

Regarding the .container: I started to overthink a lot, and made my .container extremely large in terms of attributes inside, so I can't really call it generic afterwards. As far as I know, there should be only width, max-width, and margin: 0 auto;. Should I just make another div inside the .container where I would include things like box-shadow, border-radius and background, or just make an additional class and append to existing div?

Image tag <img>: Is it a good practice to have my <img> wrapped inside separate div? Or it just depends how I implement flexbox to such things if I were to use it on this specific image? Also, I've added a fixed height: 288px; and width: 288px; to the qr code image, but I'm very unsure if that's proper way of doing that. Please help!

Lastly, margin on .qr-title in em units. When I do 1.5em for margin-top, it shows as 33px, not 24px in Dev Tools, but when I do it in px instead of ems everything fine in Dev Tools. Any ideas on why this is happening?

Code
Loading...

Please log in to post a comment

Log in with GitHub

Community feedback

No feedback yet. Be the first to give feedback on Aiden's solution.

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.