Design comparison
Solution retrospective
how can I improve my code pls? responsive design is my biggest issue how can improve it? thank you!
Community feedback
- @correlucasPosted about 2 years ago
๐พHello again Anass, Congratulations on completing this challenge!
Two tips about responsiveness to improve the NFT Card:
1.Your component is perfect, but is not responsive yet, this is due the
fixed width
you've applied to the container.Look bothwidth
andmax-width
the main difference between these properties is that the first(width) is fixed and the second(max-width) isflexible
, for example, a component withwidth: 340px
will not grow or shrink because the size will be ever the same, but a container withmax-width: 340px
ormin-width: 340px
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
..nft-card { display: flex; background: hsl(216, 50%, 16%); max-width: 270px; height: 460px; border-radius: 10px; flex-direction: column; align-items: center; position: relative; }
2.A best practice to have all the image inside the container scaling and respecting the size of the container, you need to add
max-width: 100%
and add alsoobject-fit: cover
to make the image auto-crop when resizing inside the column:img { display: block; object-fit: cover; max-width: 100%; }
โ๏ธ I hope this helps you and happy coding!
Marked as helpful1
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