Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

responsive product preview card

@istiefanus

Desktop design screenshot for the Product preview card component coding challenge

This is a solution for...

  • HTML
  • CSS
1newbie
View challenge

Design comparison


SolutionDesign

Community feedback

@weldu0

Posted

👋 Hey, @istiefanus!

Use <picture> for Responsive Images

<picture>
  <source srcset="images/desktop.jpg" media="(min-width: 48rem)">
  <source srcset="images/mobile.jpg" media="(max-width: 47.99rem)">
  <img src="images/desktop.jpg" alt="Product image">
</picture>

The HTML code above tells the browser to use images/mobile.jpg when the viewport width is less than 48rem. Otherwise, it will use images/desktop.jpg as the default image.

You don't need to use display: none; on specific breakpoints, as the <picture> element automatically selects image according to media=""

If you want to learn more about <picture>, here is greet doc from MDN. 📚

I hope this helps you. 😊

0

Please log in to post a comment

Log in with GitHub
Discord logo

Join 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