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

Responsive QR Code Using HTML and CSS

Stephengrammy•60
@Stephengrammy
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?

Thanks to using the positioning selector in CSS I was able to center the content and make it responsive on all platforms so that helped me skipped the need of writing media query code

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

First off I had issues with aligning my main-container div to the center of the page I had to look up the best way to position it on and what i found worked like a magic and it made the page responsive on all platforms .

Secondly getting the perfect width for the image was a little bit tough I had to try a lot number in px and % .

Padding too was something i had to retry a couple of time cause the sub-container div was gluing to the side of the main-container div

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

I would love see someone else CSS code and how they structured it

I definitely don't know to use figma and i was unable to open the figma design tried importing to the figma app but got an error message saying file is unsupported

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • lazyneedle•60
    @Iamnotn3rd
    Posted 7 months ago

    use :root pseudo class style to make global css variables. that'll help a lot with various color. also use text-align: center to make main content to be aligned in the center.

    Marked as helpful
  • P
    RogeanCosta•200
    @RogeanCosta
    Posted 7 months ago

    I just learned from your code a new way to center a container totally in the center, I had never thought of this possibility of using absolute positioning 😮.

    I recently did this challenge too, and I used the tactic of defining a container with a dimension smaller than that of the parent container, the body in this case (which seems obvious when looking at the design provided) and using margin-left and margin-right in auto. Having both in auto, makes them both have the same size and then the container is centered horizontally, however, I couldn't figure out what to do vertically 😅. I did something like:

    .main-container {
    width: 280px;
    margin: 50px auto;
    

    There is also a simple way to center with flexbox, but I believe that this already involves responsive design and is outside the scope of the challenge 🤔.

    By the way, about the .fig provided, I was able to open it in Figma online by dragging it onto the website, WITHOUT HAVING ANY PROJECT OPEN, just on the drafts screen. I don't usually use the application, so I can't give you information on how to proceed, but check if you can open it on the website, the design they provided was a great help to me. ✌

    Congratulations for the result! 😁

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