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

Responsive Product preview card using Flex and Media Queries

P
Jeronimo Palacios•300
@giropa832
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?

This is my first project using a mobile-first approach. It resulted in a much simpler code due to once finished the mobile design, it just a matter of a few minutes adjusting it to bigger screens.

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

Understanding how the tag works in HTML to serve different media to different screen sizes. With help from Claude and MDN documentation I was able to overcome the challenge.

What specific areas of your project would you like help with?

Is my CSS well-structured? Any resources to keep improving with mobile-first?

Code
Couldn’t fetch repository

Please log in to post a comment

Log in with GitHub

Community feedback

  • hitmorecode•7,540
    @hitmorecode
    Posted 7 months ago

    Congratulations well done. I took a quick look at your CSS and I have a few suggestions.

    • When you have elements with classes or id's and whenever you want to target that element, you can just target that specific class or id.
    // here you want to target the element with the class price. You went three layers deep to target `.price`.
    .card-content .price-container .price {
        font-size: 32px;
        font-family: 'Fraunces', serif;
        font-weight: 700;
        color: var(--dark-cyan);
    }
    
    // you can do it like this instead.
    .price {
        font-size: 32px;
        font-family: 'Fraunces', serif;
        font-weight: 700;
        color: var(--dark-cyan);
    }
    
    • DRY avoid repeating the same thing over and over. You have the "Montserrat" font on four different elements and you have repeated this four times. You can combine all four in one CSS rule.
    .card-content .category {
        font-size: 12px;
        color: var(--dark-grayish-blue);
        letter-spacing: 5px;
        text-transform: uppercase;
        font-family: 'Montserrat', sans-serif;
    }
    
    .card-content p {
        font-size: 14px;
        font-family: 'Montserrat', sans-serif;
        line-height: 23px;
        color: var(--dark-grayish-blue);
    }
    
    .card-content .price-container .discounted-price {
        font-size: 14px;
        font-family: 'Montserrat', sans-serif;
        color: var(--dark-grayish-blue);
        text-decoration: line-through;
    }
    
    .card-content button {
        background-color: var(--dark-cyan);
        color: white;
        border: none;
        padding: 15px 0;
        border-radius: 10px;
        font-weight: 500;
        font-family: 'Montserrat', sans-serif;
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 10px;
    }
    
    • Combine all these four into one.
    .category,
     p,
    .discounted-price,
    button {
        font-family: 'Montserrat', sans-serif;
    }
    

    With this if you ever need to change the font-family on all four, you just need to do it in one place.

    • When you add fallback fonts, it's best to do it on the body. In this case the sans-serif should be on the body.

    I hope you find this helpful. Keep it up 👌👍

    Marked as helpful
  • P
    Lo-Deck•3,740
    @Lo-Deck
    Posted 7 months ago

    Hi your link viewCode is useless error 404.

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

How does the accessibility report work?

When a solution is submitted, we use axe-core to run an automated audit of your code.

This picks out common accessibility issues like not using semantic HTML and not having proper heading hierarchies, among others.

This automated audit is fairly surface level, so we encourage to you review the project and code in more detail with accessibility best practices in mind.

How does the CSS report work?

When a solution is submitted, we use stylelint to run an automated check on the CSS code.

We've added some of our own linting rules based on recommended best practices. These rules are prefixed with frontend-mentor/ which you'll see at the top of each issue in the report.

The report will audit all CSS, SCSS and Less files in your repository.

How does the HTML validation report work?

When a solution is submitted, we use html-validate to run an automated check on the HTML code.

The report picks out common HTML issues such as not using headings within section elements and incorrect nesting of elements, among others.

Note that the report can pick up “invalid” attributes, which some frameworks automatically add to the HTML. These attributes are crucial for how the frameworks function, although they’re technically not valid HTML. As such, some projects can show up with many HTML validation errors, which are benign and are a necessary part of the framework.

How does the JavaScript validation report work?

When a solution is submitted, we use eslint to run an automated check on the JavaScript code.

The report picks out common JavaScript issues such as not using semicolons and using var instead of let or const, among others.

The report will audit all JS and JSX files in your repository. We currently do not support Typescript or other frontend frameworks.

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