Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted almost 3 years ago

Design product preview card component using css flexbox and grid

Abbas Roholamin•30
@abbas-roholamin
A solution to the Product preview card component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


Do you find it easier to work with flexbox or grid to create a responsive layout?

Code
Couldn’t fetch repository

Please log in to post a comment

Log in with GitHub

Community feedback

  • Eray•1,410
    @ErayBarslan
    Posted almost 3 years ago

    Hey there, excellent solution! It's almost pixel perfect and responsive. To answer your question, both flex and grid has their use cases. In general you can create a responsive layout with both with no issues as they can achieve similar things. When you're working with 1 column or row layout, it's generally easier to use flexbox and there are certain things grid can't achieve.

    For example there are 3 items on the page and we want them to wrap to a new row when the screen gets smaller. You can achieve it with both flex and grid; however it won't possible to center the item that's wrapped to new row with grid while flex can do. (* Won't be the case when they're all wrapped since there is just 1 row*)

    Although when the layout has several columns/rows , it's much more convenient to work with grid. Flex will just makes things harder. My advice would be to practice both and in time you'll decide easier on which to use when. Happy coding :)

    Marked as helpful
  • Abdullah•340
    @ASH2001prince
    Posted almost 3 years ago

    Hello Abbas Roholamin you did an amazing job with this project I did this project a couple days ago and I didnt use the grid in it so it didnt become responsive
    as it should be so I think that you did the best practice in here. -keep it up bro

    Marked as helpful
  • P
    Leonard•1,025
    @leoikeh99
    Posted almost 3 years ago

    Very good solution, my only feedback is:

    1. Try to already make the component responsive before reaching 425px, as it is right now the image seems to reduce in width a little too much before you applied your responsive styles.

    2. I would also advice, at a point when the screen is a small sizes to just set the components with to a certain percentage e.g. 90%, this will greatly improve responsiveness.

  • Chyunjet•620
    @Jetyun
    Posted almost 3 years ago

    hmmmm, for me, flex i will use it to arrange the element that needed to be in row or column, so that i no need to use margin or anything to make them tidy, just use justify or align to space each element neatly with each other. In this challenge, i use flex to change the image from the top (mobile view) to the side (desktop view) from column to row.

    for grid, i think it is best to use it when you have a lot of boxes of content. Imagine that instead of one picture and a textbox side by side, you will have to code 4 more, each with different sizes. On that situation, i will use grid-template-areas to set the template of the design. if you need to amend the size, just go to the grid-template areas to amend the size, no need to set margin and/or padding, width or height on each boxes.

    You should try Testimonials grid section challenge and 3-column preview card component challenge to get the idea on usefulness on grid template area

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

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