Design comparison
Solution retrospective
I was able to make it look pretty close to my eye and since I only had a static image to work with I think it is pretty close. My question to any more experienced people is how do you make so gradually shrink? I was able to make two layouts, one for desktop and one for mobile but it just snaps into place it doesn't gradually shrink into the smaller size. Any help is much appreciated as well as feedback!
TomoFromEarth
Community feedback
- @correlucasPosted over 2 years ago
πΎHello TomoFromEarth, congratulations for your new solution!
Answering your question:
To make the container
shrink
you've to fix the issuefixed width
you've applied to the container.The main difference between
width
andmax-width
is that the first property is fixed and the second isflexible
, for example, a component withwidth: 28rem
will not grow or contract because the size will be ever the same, but a container withmax-width: 28rem
ormin-width: 28rem
can grow or contract depending of the property you've set for the container. So if you want a responsive block element, never usewidth
choose ormin-width
ormax-width
..main-container { display: block; margin-top: 8rem; margin-bottom: 8rem; border-radius: 1.75rem; text-align: center; /* height: 43rem; */ max-width: 28rem; padding: 16px; background-color: hsl(0, 0%, 100%); }
Make the image responsive and scale with the container size using
display: block
andmax-width: 100%
. Look the changes I've done to your code:#image { /* border-radius: 1.25rem; */ /* width: 90%; */ /* height: auto; */ /* margin: 1.25rem; */ } img { display: block; max-width: 100%; }
π I hope this helps you and happy coding!
Marked as helpful0@TomoFromEarthPosted over 2 years ago@correlucas thank you so much for the reply and detailed explanation. I remember learning this now and youβve jolted it back into consciousness lol. Thank you again!
0 - @vanzasetiaPosted over 2 years ago
Hi there! π
Congratulations on completing your first Frontend Mentor challenge! π
For the responsiveness of the card, there's no need for media queries. The only thing that the card needs to be responsive is a
max-width
. This way, the card width is limited to prevent the card from filling the entire page horizontally. Also, it still allows the card to shrink if ever needed.So, I recommend removing the
width
andheight
from the card styling. For the height of the card, let the elements inside the card control the height of it. This way, if you change the page content or the size of the elements, the card can automatically adjust the height to fit the content.More suggestions for improvements.
- Use
main
tag instead ofdiv
withrole="main"
. Semantic HTML should be the first thing that needs to be used whenever possible. - I suggest fixing the alternative text for the QR code. Telling the users about the background color of the QR code is not providing useful information. Instead, tell the users about the QR code.
- The styling of the card on desktop and on mobile is the same. So, you won't need to use any media queries to make the site responsive.
- Avoid using
br
elements for presentational purposes. Read what MDN documentation says about it.
That's it! I hope this helps! Happy coding! π
Marked as helpful0@TomoFromEarthPosted over 2 years ago@vanzasetia thank you so much I really appreciate the feedback and will implement the changes you suggested.
1 - Use
- @VCaramesPosted over 2 years ago
Congrats on completing this challenge!
To answer your question, you want to change your
width
in your main-container class tomax-width
and deletemargin-top
,margin-bottom
, andheight
; they're not needed.Some other suggestions:
To center your card, add
min-height: 100vh
andjustify-content: center
to your Body Element.Marked as helpful0@TomoFromEarthPosted over 2 years ago@vcarames thanks so much for the response it is much appreciated!
0
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