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

QR Code component solution

Landiel•100
@LandielDurans
A solution to the QR code component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


Hello, I'm Brazilian, and this is the first project that I do and share, everything is still new to me, I hope I can count on the help of the community and that they can help me grow even more in this journey as a developer in development.

Code
Couldn’t fetch repository

Please log in to post a comment

Log in with GitHub

Community feedback

  • Abdul Khaliq 🚀•72,380
    @0xabdulkhaliq
    Posted over 2 years ago

    Hello there 👋. Congratulations on successfully completing the challenge! 🎉

    • I have other recommendations regarding your code that I believe will be of great interest to you.

    CSS 🎨:

    • Looks like the component has not been centered properly. So let me explain, How you can easily center the component without using margin or padding.

    • We don't need to use margin and padding to center the component both horizontally & vertically. Because using margin or padding will not dynamical centers our component at all states

    • To properly center the component in the page, you should use Flexbox or Grid layout. You can read more about centering in CSS here 📚.

    • For this demonstration we use css Grid to center the component
    body {
        min-height: 100vh;
        display: grid;
        place-items: center;
    }
    
    • Now remove these styles, after removing you can able to see the changes
    .container {
      padding: 120px;
    }
    


    • Now your component has been properly centered

    . BODY MEASUREMENTS 📐:

    • The width: 100% property for body element is not necessary. because body is a block level element which will take the full width of the page by default.

    • So feel free to remove width: 100% style rule from body

    .

    I hope you find this helpful 😄 Above all, the solution you submitted is great !

    Happy coding!

    Marked as helpful
  • Bader Idris•2,880
    @Bader-Idris
    Posted over 2 years ago

    You can set the container in the middle of the screen whatever user changes it when you add these properties to it in CSS:

    .container {
      display: absolute;
      top:50%;
      left: 50%;
      transform: translate(-50%, -50%);
    }
    

    the new feature is transform, it has many lovely properties you can discover, I personally love it. Hope it's useful

  • lepamoore•170
    @lepamoore
    Posted over 2 years ago

    Hey Landiel 👋, Your code looks very nice ! Much better than my first project here, lmao. I just read it and want to give you some feedback.

    • First, for body HTML and DIV tags, you don't need to specify the width to 100%. For these elements, the width is automatically set to 100%.

    • Then I recommend using the units % or vw (view-width) and vh (view-height) for width and height of a div or a similar element. When you use the % unit, e.g. width: 50%; Your element will be as half as big as the parent element because the % unit takes the height or width value of the parent as 100%. When you use width: 50vw; it's the 50% of the viewpoint width or device width. Same for height: 50vh; it's 50% of the viewpoint width or device width.

    • When you use these relative units, your elements will grow and shrink as the browser does. You can set maximum or minimum values in px. you could use this CSS rule as an example: div {height: 50vh; min-height: 200px;} in this case, your div container is half as big as the height of the browser window, but it won't get smaller than 200px. That means, even if your browser window is 300px high, your div will remain 200px high.

    • I saw you used some flexbox to center your divs. That was pretty nice, i just noticed you only used justify-content with flexbox. justify-content is as you know for the horizontal alignment. And if you use align-items: center; as well, your element will be fully centered.

    <div id='parentDiv'>
      <div id='childDiv'></div>
    </div>
    
    #parentDiv {
      display: flex;
      align-items: center; 
      justify-content: center;
      background-color: blue;
    }
    
    #childDiv {
      height: 50%;
      width: 50%;
      background-color: white;
    }
    
    • above you can see the code for a fully centered div in another one. Feel free to copy it and run it in the browser to get a better understanding of what I mean. My English isn't the best, so I hope you can understand what I mean 😅.

    • another important thing is use for further description of an image, an alt attribute. don't use title='this image shows a chair'. Use alt='this image shows a chair'. This way people who are using the internet with screen readers can hear your pictures then instead of seeing them.

    • keep it up. I'm just new to coding like you, but I hope my hints or tips were helpful to you. Greetings and Happy coding! 😉

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.

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