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 using basic HTML and CSS

Djengis05 30

@DarkGamerXDOFF

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


I've had most problems with centring the card. I ended up using flexbox for this but was this the best solution? Also, what would be a more efficient way to manage the card size?

Community feedback

Koli 110

@KoliOyama

Posted

Yes, you were right to use flexbox. Just to clarify;

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

Using justify-content: center, the container will be set at the horizontal center. While align-items: center will set it at the vertical center.

With grid:

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

As for managing the widths, try making use of the max-width property for the containers. This will restrict it from stretching with your browser window. I hope this helps ;⁠)

0
d8701a 240

@d8701a

Posted

Hi!

Using flexbox to center elements or for layouts in general is a good idea. So you made a good call when you decided to use it in this case. There are other ways of horizontally centering elements, such as using margins: (margin: 0 auto), using transform: translate(-50%, -50%) but this also requires an element to be absolutely positioned so I'd avoid this one, using grid and of course - using flexbox. For a simple layout like this, flexbox seems like a perfect use case.

When it comes to managing the card size, I believe the priority should be its responsiveness. It should be able to change it's dimensions depending on the screen size. For this, try learning more about setting width with one of these three things: min(), max() and clamp() function. For more information on these, check this article: https://web.dev/min-max-clamp/

0

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