Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted over 2 years ago

Product Preview Card Component - Mobile-First Solution

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

Solution retrospective


This was my first project that I consciously tried to approach with a mobile-first design workflow. After finishing the mobile design, I was surprised at how easy it was to get the desktop design working properly with a media query. I also challenged myself by incorporating a little CSS Grid where I would normally be more comfortable with Flexbox.

I had some trouble getting the image to display properly. It took a lot of trial and error. I got it working, but I still don't fully understand why the properties I used worked the way they did.

I ended up using a container div and a background-image property with the image URL (using a media query to change it between desktop/mobile). I used "background-size: cover" and "background-position: center top". Do these properties make sense here or is there a better way to set up the image for this project?

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 ryangholland'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