Skip to content
  • Learning paths
  • Challenges
  • Solutions
  • Articles
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted over 1 year ago

QR component using CSS Flexbox and Google Fonts

Rico98•10
@CesarQD98
A solution to the QR code component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


I found difficult using flexbox when the flex-direction is set to column. Not that sure if flexbox is the only way to position the QR Component in the center of the screen. I've heard of margin: auto but couldn't make it work. Feedback is absolutely welcome!

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Melvin Aguilar 🧑🏻‍💻•61,060
    @MelvinAguilar
    Posted over 1 year ago

    Hello there 👋. Good job on completing the challenge !

    I have some suggestions about your code that might interest you.

    • Using display: flex; is a very common way to center elements. Another alternative is to use the grid layout.

      body {
        display: grid;
        min-height: 100vh;
        place-items: center;
      }
      

      Another way to center an element is using display: absolute but it may introduce issues on smaller devices. The component might overflow or cause layout problems.

      If you choose to use margin: auto; for centering, keep in mind that it won't center vertically, only. For vertical centering, you can use flexbox with margin: auto:

      body {
        display: flex;
        min-height: 100vh;
      }
      
      .item {
         margin: auto;
      }
      

    I hope you find it useful! 😄

    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
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

Oops! 😬

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

Log in with GitHub