Skip to content
  • Learning paths
  • Challenges
  • Solutions
  • Articles
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted almost 3 years ago

product preview using HTML, CSS flexbox and advanced selectors

Christ Kevin Touga Watat•270
@Christ-Kevin
A solution to the Product preview card component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


I don't have a particular question on this project but I would be grateful for any suggestions that can make me improve my coding skills

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Alex•2,010
    @AlexKMarshall
    Posted almost 3 years ago

    This is looking very good, there's just a few things that would be worth taking a look at

    The add to cart button:

    • you've used a div wrapping an anchor tag that has the add to cart text in it. So, while the hover effect covers the whole div, the clickable target doesn't. A user would only be able to click on the text.
    • this should really be a button. In html anchors are navigating to another location, and buttons are for executing some other action like a form submission or triggering some javascript. Here adding to cart is an action, not a navigation

    The perfume ribbon text:

    • You've written P E R F U M E directly in the html. A screen-reader will read that as individual letters, not a word
    • Instead, write Perfume in the html, and then use css text-transform and letter-spacing properties to style it like the design

    The prices section:

    • You've used flexbox here, but have had to use 4 non-breaking spaces to create the gap between the prices
    • use gap instead for more flexibility
    • In addition, on very tiny screens, or high zoom levels, you get overflow here. To avoid that add flex-wrap: wrap so it can wrap onto a new line if there's not enough space for it to fit in one line

    The image:

    • this is part of the product card, so should go inside <main>
    • you've used object-fit: fill, so at a couple of screen-sizes the image stretches out of its aspect-ratio. To avoid that use object-fit: cover

    In general though these are mostly fairly minor points that are easily fixed.

    Well done for making it very responsive, avoiding almost all overflow, writing good alt text for the image

    Marked as helpful

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
Frontend Mentor logo

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

Frontend Mentor

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

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

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Frontend Mentor for Teams

Frontend Mentor for Teams helps companies and schools onboard and train developers through project-based learning. Our industry-standard projects give developers hands-on experience tackling real coding problems, helping them master their craft.

If you work in a company or are a student in a coding school, feel free to share Frontend Mentor for Teams with your manager or instructor, as they may use it to help with your coding education.

Learn more

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub