Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

QR code component solution

Kingaโ€ข 150

@K-Muzslay

Desktop design screenshot for the QR code component coding challenge

This is a solution for...

  • HTML
  • CSS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


This is my first attempt here, I hope I did everything right. I struggled more with setting up GitHub than solving the challenge.

My major problem, during the challenge, was positioning the div which holds the image to the center of the page. If you can show me a more practical way to do that, I would be very happy.

Community feedback

@MelvinAguilar

Posted

Hi @K-Muzslay ๐Ÿ‘‹, good job for completing this challenge and welcome to the Frontend Mentor Community! ๐ŸŽ‰

Answering your question here are some suggestions to improve your code:

There are two modern CSS techniques to center elements

Using flexbox layout:

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

Using grid layout

body {
   width: 100%;
   min-height: 100vh;
   display: grid;
   place-content: center;
}

More information:

And remove:

main {
    /* margin: 0; */
    /* position: absolute; */
    /* top: 50%; */
    /* left: 50%; */
    /* -ms-transform: translate(-50%, -50%); */
    /* transform: translate(-50%, -50%); */
}

Another tips:

  • Use max-width: 360px to .container selector instead of width.
  • Use margin: 0.625rem or margin: 10px in the container selector so that it has some space when viewed on mobile devices.

I hope those tips will help you.

Good Job and happy coding !

Marked as helpful

1

Kingaโ€ข 150

@K-Muzslay

Posted

@MelvinAguilar Thank you so much! I was sure it can be solved with flexbox, I tried but I was not familiar with the "vh" relative unit. Now I'll keep it in mind.

I haven't learnt grid yet, I will revisit this when I'm at it.

Thank you for the extra tips too!

1

Please log in to post a comment

Log in with GitHub
Discord logo

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