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 using picture tags and flexbox

P
Eli Silkā€¢ 240

@elisilk

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


What are you most proud of, and what would you do differently next time?

I spent a bit more time on this project making sure that the design worked for all screen sizes from a viewport width of 320px up to more than 1440px.

What challenges did you encounter, and how did you overcome them?

Thanks to amazing suggestions of @DylandeBruijn and @danielmrz-dev, I started with a clunky solution that involved using background images for the photos, and moved toward a much more flexible responsive images solution that works well across screen sizes and treats the product images as part of the content.

Community feedback

Daniel šŸ›øā€¢ 44,230

@danielmrz-dev

Posted

Hey there! šŸ™‹šŸ½ā€ā™‚ļø

Congrats on finishing the challenge! āœ…

Your project looks awesome!

Here's a tip that might interest you:

šŸ“Œ When you have different versions of the same image, consider using the <picture> tag. Using it as a background works, but in this case, the image is not only decorative, it's part of the content.

This will help ensure the correct image loads on the user's device, saving bandwidth and boosting performance.

Example:

<picture>
    <source media="(min-width: 768px)" srcset="{desktop image path here}">
    <img src="{mobile image path here}" alt="{alternative text here}">
</picture>

Hope you find this useful!

Great job overall!

Marked as helpful

0

P
Eli Silkā€¢ 240

@elisilk

Posted

@danielmrz-dev, thank you for the excellent suggestion and clear example. I have replaced my background images with the picture tag as you suggested and I think it's a much better solution. I appreciate the help!

0
Dylan de Bruijnā€¢ 3,190

@DylandeBruijn

Posted

@elisilk

Hiya! šŸ‘‹

Congratulations on your solution, it looks very close to the design! I can tell you put a lot of effort into it.

Things I like about your solution šŸŽ‰

  • Use of semantic HTML elements
  • Clear descriptive CSS classes
  • Use of CSS custom properties

Things you could improve āœļø

  • You could add a min-height: 100vh to your body element so it takes up the full height of the viewport while still being able to grow when the content inside it grows.

  • Try using using relative CSS units like rem and em they make your layout more adaptable.

  • I recommend looking into the picture element to achieve the desired effect of having different images on different viewports.

  • I recommend using a p tag for the category.

I hope you find my feedback helpful! šŸŒŸ

Let me know if you have more questions and I'll do my best to answer them. šŸ™‹ā€ā™‚ļø

Happy coding! šŸ˜Ž

Marked as helpful

0

P
Eli Silkā€¢ 240

@elisilk

Posted

@DylandeBruijn, wow! Thank you for looking so carefully at the code and making such great suggestions. I implemented them all and I think my solution is much better as a result. I really appreciate the help!

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