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

Product Preview Card Component

P
Stefan 90

@Saitenhexer

Desktop design screenshot for the Product preview card component coding challenge

This is a solution for...

  • HTML
  • CSS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


The responsive part gave me some headache. I switched the card to grid-layout to make it work. Maybe not the best solution but i'm happy with it.

Community feedback

@ahmedafsa

Posted

Hello @Saitenhexer, Good job!

You can employ the <picture> element with <source> tags and media queries to make the product image responsive

  • HTML:
<picture>
  <source
    srcset="images/image-product-mobile.jpg"
    media="(max-width: 600px)"
  />
  <source
    srcset="images/image-product-desktop.jpg"
    media="(min-width: 601px)"
  />
  <img src="images/image-product-desktop.jpg"/>
</picture>
  • CSS:
@media (max-width: 600px) {
  .your-grid-container {
    grid-template-columns: 1fr;
  }
}

Marked as helpful

0

P
Stefan 90

@Saitenhexer

Posted

@ahmedafsa

Thank you! Thats is a nice way to change the picture!

I will try it :)

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