Design comparison
Community feedback
- @StroudyPosted about 2 months ago
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%
ormin-width: 100%
is more responsive than justwidth: 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, userem
orem
, 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 helpful1@cmoissPosted about 2 months agoHello, @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 adisplay: 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@StroudyPosted about 2 months agoHey, @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 yourmain-container
heremargin: 2rem auto;
and add thismargin-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 aboutem
just avoid usingpx
.Marked as helpful1 - If you put this code snippet into your
Please log in to post a comment
Log in with GitHubJoin 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