Submitted over 1 year ago
Product Preview Component - Media Queries for Desktop & Mobile
@codarose
Design comparison
SolutionDesign
Solution retrospective
Is there a better way to get the image to scale in the desktop view than using "object-fit: cover" ?
Is there a way other than media queries to use two separate images for desktop and mobile?
Community feedback
- @savvystriderPosted over 1 year ago
- You can use
background-size: cover
to display the image as a background image and then use thecover
property to scale it. - You can add
max-width: 100%
to all images to make sure that images don't get any larger than they are supposed to be. - You can also use the
transform: scale
property to scale the image. - Also, you can use the HTML picture element "to offer alternative versions of an image for different display/device scenarios."
Hope this helps! I think your project came out well, regardless.
0 - You can use
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