@elaineleung
Posted
Hi Angel Iran, good job putting this together! It looks like your image is slightly distorted, but no worries, that can be fixed with object-fit
by adding object-fit: cover
to your img
element.
I see you using a breakpoint of 376px; the tricky thing is your component overflows off the screen until the breakpoint changes. Since the component is about 600px in desktop view, I suggest a breakpoint slightly higher than that (e.g., 620px). The other problem I see is that, you only have the mobile image in the HTML. You can use the picture
element in your HTML by adding these lines around your <img>
:
<picture>
<source srcset="./images/image-product-desktop.jpg" media="(min-width: 620px)">
<img src="./images/image-product-mobile.jpg" alt="">
</picture>
Lastly, to center everything, use display:grid
on your body selector, like this:
body {
display: grid;
place-content: center;
min-height: 100vh;
}
Well done!
Marked as helpful
2
@angeliran
Posted
@elaineleung Thank you very much for your advice
1