Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted 6 months ago

Product preview card component challenge

carodg09•80
@carodg09
A solution to the Product preview card component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


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

I figured out how to use <picture> and srcset properly for different screen sizes. Next time I’m hoping to try Sass to make my styles more organized.

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

One challenge I faced was getting the product image to align correctly and fill exactly half of the container without stretching or leaving empty gaps. I struggled with how object-fit, width, height, and flex interact. After experimenting and checking layout behavior in the browser, I realized that I needed to explicitly set both the image and its container to height: 100% and use object-fit: cover to achieve the desired result.

Code
Loading...

Please log in to post a comment

Log in with GitHub

Community feedback

No feedback yet. Be the first to give feedback on carodg09's solution.

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

Stay up to datewith new challenges, featured solutions, selected articles, and our latest news

Frontend Mentor

  • Unlock Pro
  • Contact us
  • FAQs
  • Become a partner
  • Use cases

Explore

  • Learning paths
  • Challenges
  • Solutions
  • Articles

Community

  • Discord
  • Guidelines

For companies

  • Hire developers
  • Train developers
© Frontend Mentor 2019 - 2025
  • Terms
  • Cookie Policy
  • Privacy Policy
  • License