Responive Product Preview Card Using CSS Grid and Flexbox
Design comparison
Solution retrospective
I found spacing decisions and layout the most challenging. For example, I've read that it's best to shy away from declaring font-size in pixels, but saw pixel size in the Figma design file. What is best practice?
I had the same questions around layout - how exact does spacing between items need to be?
Community feedback
- @WebDevMirzaPosted almost 2 years ago
Hello, congratulations on completing this project successfully.
Your query was how to use units in css. Well, there are two types of unit available in css. One is absolute unit and the other one is relative. If you design a responsive layout, you should go for relative unit. Both
em
andrem
are relative unit based on parent and root font size respectively.rem
is the best for font-size.bootstrap
andtailwind
use these relative units, even in margin and padding.
NB: This does not mean that
px
is useless. Use it when you feel it.Thank you.
Marked as helpful0 - @HassiaiPosted almost 2 years ago
To center .product on the page using grid, replace align-items: center with align-content: center. when centering items in grid, justify-content goes with align-content and justify-items goes with align-items. unlike flexbox which is always justify-content and align-items.
Use relative units like rem or em as unit for the padding, margin, width values and preferably rem for the font-size values, instead of using px which is an absolute unit. For more on CSS units Click here
Hope am helpful.
Well done for completing this challenge. HAPPY CODING
Marked as helpful0
Please log in to post a comment
Log in with GitHubJoin 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