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 card component using Flexbox

@abilioassis

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


Not all content present in HTML needs to be displayed at all times.

For example, depending on the screen size (desktop and mobile) the component image changes.

I placed the two images in the HTML and in the CSS I controlled the visibility using the display property.

And you? How did you solve this problem?

Community feedback

@MelvinAguilar

Posted

Hi @abilioassis 👋, good job completing this challenge! 🎉

I like this solution for the challenge.

  • You can use a <picture> tag when you need to change an image in different viewports. Using this tag will prevent the browser from loading both images, saving bandwidth and preventing you from utilizing a media query in your css file to modify the image.

Example:

<picture>
   <source media="(max-width: 375px)" srcset="./images/image-product-mobile.jpg">
   <img src="./images/image-product-desktop.jpg" alt="your_alt_text">
</picture>

Good job, and happy coding! 😁

Marked as helpful

1

@abilioassis

Posted

Hi @MelvinAguilar! Wow! This tip was wonderful! I didn't know this way of doing it. Thanks again.

1

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