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
Desktop design screenshot for the QR code component coding challenge

This is a solution for...

  • HTML
  • CSS
1newbie
View challenge

Design comparison


SolutionDesign

Community feedback

P
Steven Stroud 4,240

@Stroudy

Posted

Congratulations on your first solution, Amazing job with this! You’re making fantastic progress. Here are some small tweaks that might take your solution to the next level…

  • If you put this code snippet into your body you can center your container vertically,
  min-height: 100svh;
  display: flex;
  justify-content: center;
  flex-direction: column;
  align-items: center;
  • min-height: 100svh;: Sets the minimum height to 100% of the small viewport height.

  • display: flex;: Enables flexbox for flexible layout.

  • justify-content: center;: Centers content vertically.

  • flex-direction: column;: Stacks items vertically.

  • align-items: center;: Centers content horizontally.

  • .

  • Avoid using id selectors for styling in CSS because they are too specific and hard to override, making your styles less flexible and maintainable. Instead, use class selectors (.), which are reusable and more manageable, allowing for better control over your styles and easier updates.

  • Using max-width: 100% or min-width: 100% is more responsive than just width: 100% because they allow elements to adjust better to different screen sizes. To learn more, check out this article: responsive-meaning.

  • Developers should avoid using pixels (px) because they are a fixed size and don't scale well on different devices. Instead, use rem or em, which are relative units that adjust based on user settings, making your design more flexible, responsive, and accessible. For more information check out this, Why font-size must NEVER be in pixels or this video by Kevin Powell CSS em and rem explained.- Another great resource for px to rem converter.

You’re doing fantastic! I hope these tips help you as you continue your coding journey. Stay curious and keep experimenting—every challenge is an opportunity to learn. Have fun, and keep coding with confidence! 🌟

Marked as helpful

1

@cmoiss

Posted

Hello, @Stroudy!

Thank you so much for your help, this will be great for me. :)

However, I have some doubts:

  • In simple layout situations like this, is it more worthwhile to use margin: auto to center a container in a display: block, or is it actually better to use a flex display on its parent?

  • I would also like to know if it is worth using media queries even if I have no change in the layout, as in this challenge.

  • Also, I'm still in doubt about how to use the em and rem units, in which situations should I use each?

0
P
Steven Stroud 4,240

@Stroudy

Posted

Hey, @cmoiss,

1 - If you are trying to center left and right use margin-inline: auto, to center vertically here i would use this code snippet above. Remove this from your main-container here margin: 2rem auto; and add this margin-inline: auto,

2. For this challenge no I would not but you can experiment with them if you like for future challenges but there will plenty of chances to play around with these.

3. Majority of the time you use rem while you are learning, Dont worry to much about em just avoid using px.

Marked as helpful

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