Somewhat responsive page using css grid
Design comparison
Solution retrospective
Tried using the picture element and the img element with srcset to have the images switch at certain breakpoints but the browser was reading only the src image so it was not working, eventually i switched to background img with media query breakpoint, but the mobile img zoomes in as you increase the with of the viewport.
Any advice would be appreciated!
Community feedback
- @VCaramesPosted over 2 years ago
Good job on your project!
Since this a product card, it really isn't meant to continuously expand like like full website; it should have two fixed designs... mobile and desktop.
To fixed how you card looks in mobile view, change the
width
size in your wrapper class to 375pxNext, change the
min-width
of yourmedia
to 610px and add amax-width
of 600px to your wrapper class (in the media section).With those changes your card should look the way you want it to.
Happy Coding!
Marked as helpful1@AlexandruStefanGherhesPosted over 2 years ago@vcarames Reading your comment it actually makes sense having the mobile set a max 375px. Thank you for your advice.
0 - @warrenleePosted over 2 years ago
Hey Alexandru, good work on the challenge, I think how you tackle the image using background-image with grid works well quite! But as you've pointed out the image for mobile zooms and that's because of the CSS property
background-size: cover
and the also the way grid cells behave where all cells have the same dimensions according to the large cell.If you want to look back into the
picture
solution again have a look at my take on this. https://bitbucket.org/warrenlee/frontend-mentor/src/7d9890d17383b78420d658897ccfe816ee62f71a/product-preview-card-component/index.html#lines-14:17 Just make sure you usemedia="min-width: XXpx"
rather thanmax-width
in the source tag and make the source cascade so that largemin-width
starts from the top.Hope that helps!
Marked as helpful1@AlexandruStefanGherhesPosted over 2 years ago@warrenlee Thank you for the insight regarding the picture element, following your example mine works as it should.
1
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