Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted about 1 year ago

QR Code Component with Semantic HTML Elements

Levi Kuhaulua•220
@LeviKuhaulua
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 am most proud of the responsiveness of the QR Code Component. Initially, when I had it, the text or image would overflow outside of the card and really got me thinking as to how I could solve it. When I was able to solve, that feeling was great because I had made a component that looked good across different screen sizes without needing to use a media query.

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

My challenges came off with figuring out which semantic HTML elements to use and also how to import web fonts.

When it came to the HTML elements, I consulted the Mozilla Web Docs - HTML to see what attributes were widely supported and their use cases to help me decide which elements to use in my source code.

For web fonts, I decided to follow the documentation in the Google Fonts API support and used the link tag to import the font-family then create a CSS class to get the two font variants.

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

My implementation for getting the card component to be in the middle of the screen was to do the following:

.container {
    position: absolute; 
    top: 50%; 
    left: 50%; 
    translate: -50% -50%; 
} 

Initially, I was planning to position the card component using Flex but was having issues regarding the positioning. The way I had it was to make the body tag have a display of flex then do flex-direction: column, justify-content: center, and align-items: center but noticed that the card was still positioned at the top. I was wondering the different ways you could position the card component in the middle using Flex or Grid and also the benefits of using those methods versus the implementation I had done above.

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Koda👹•3,830
    @kodan96
    Posted about 1 year ago

    hi there! 👋

    You can center your content with Flexbox, but you have to specify height for the body tag. Without that flexbox won't center the content. So your code should look like this:

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

    Use min-height, otherwise users won't be able to scroll down if your content does't fit into one screen on smaller screen sizes.

    Hope this helped 🙏

    Good luck and happy coding!

    Marked as helpful
  • bmuia•60
    @bmuia
    Posted about 1 year ago

    add the height property to body

    body { height: 100vh; ...... }

    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

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 1st-party linked stylesheets, and styles within <style> tags.

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.

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