Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted about 1 month ago

Responsive card using CSS Grid for Layouts and Flexbox for alignments.

P
Paola Perez•50
@Perezscode
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'm proud that I built a responsive layout using CSS Grid and Flexbox and solved tricky styling issues like aligning the original price and discount price properly. This helped me understand how layout and spacing work together.

Next time, I would plan my layout structure better before writing the code. I spent a lot of time adjusting spacing and fixing alignment issues that I could’ve avoided with a clearer wireframe or sketch.

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

One challenge I faced was getting the two-column layout to look clean without breaking the alignment, especially when adding padding to the content side. It was tricky because even small spacing changes affected the entire card’s balance, especially with the image on the left.

I fixed it by using grid-template-columns with 1fr 1fr, then adding padding only to the content side and making sure box-sizing: border-box was applied. I also used align-items: center to keep everything vertically aligned, which helped keep the layout consistent across screen sizes.

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

I’d like help improving how the card layout behaves across different screen sizes. Specifically, I want to make sure the image and content stack properly on mobile without breaking the design. I’m also looking for better ways to manage spacing so that the layout stays balanced without needing too many manual tweaks. However, I'm proud of my work because I figured a lot out on my own.

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Ezequiel•1,250
    @3eze3
    Posted about 1 month ago

    Hi , very good solution for this challenge, Paola Perez 🍕

    I have some recommendations that may help you in your future projects:

    General:

    • Having a solid code structure is key when starting any project, i know I'm projects are practical but getting used to already have or create your own structure will save you time believe me.
    • The way in which you handle the styles in cellular seem to me good, as for the images there is a tag ``<picture>``` which you can use to dynamically change the image depending on the size of your screen.
    <picture>
      <source media="(min-width: 768px)" srcset="./images/image-product-desktop.jpg">
      <img src="./images/image-product-mobile.jpg" alt="Perfume bottle" width="300">
    </picture>
    
    

    HTML:

    • The semantics in your code can be improved, see if you can wrap it instead of using a <div> it could be a <section> or a <main> for better semantics.

    CSS:

    • Also instead of calling the fonts directly from the html document, the best and most recommended is to have them locally and use the @font-face to use them, it is much better, since you can also centralize them in the same file when you launch larger projects.

    I hope these recommendations have been helpful to you. Keep it up, and if you ever have any questions or get stuck on something, feel free to contact me on LinkedIn.

    Happy coding! 🍧

  • P
    Paola Perez•50
    @Perezscode
    Posted about 1 month ago

    Feedback is welcome!!! Any suggestions on how my code could've been better?

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 1st-party linked stylesheets, and styles within <style> tags.

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.

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