Submitted over 2 years ago
Product preview card component responsive using only css
@DevEliezerMartinez
Design comparison
SolutionDesign
Solution retrospective
I have some problems using <picture> there is a minimal space in mobile version between the image and the description
Community feedback
- @elaineleungPosted over 2 years ago
Hi Eliezer, the space comes because
img
andpicture
are more like inline elements than block ones unless you specify. Try adding this to the top of your CSS under the*
rules:picture, img, svg { max-width: 100%; display: block; }
Two other quick comments:
- The desktop image looks distorted right now, so try to add a
object-fit:cover
on theimg
. - You only got the mobile image right now; try adding the desktop one within the picture element so that the browser can switch to it at the breakpoint, like this:
<picture id="product"> <source media="(min-width: 620px)" srcset="images/image-product-desktop.jpg" /> <img src="images/image-product-mobile.jpg" alt="picture of lotion "> </picture>
Well done overall!
Marked as helpful0 - The desktop image looks distorted right now, so try to add a
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