Product Preview Card Component made by ActuallyWIKKO
Design comparison
Solution retrospective
It took a bit to get the hang of this but it was very satisfying seeing the result, tweaking even the tiny details to make it good to go. It was quite fun.
I would definitely use this document as a future reference on how to set up a card component.
What challenges did you encounter, and how did you overcome them?First I struggled with alignments and flex box. When I was looking up examples I got the hang of it pretty quickly and wrote my own.
A struggled a little getting the media query set up with the images switching. Turns out I was overthinking it and in the past couple of years it got wayyy easier to do this inline in HTML.
There were a couple of little things too that I had to look up, like transforming the scale of the H2 to make it look more squished or setting the old price to appear centered to the new price (not displaying it on the baseline).
What specific areas of your project would you like help with?I'd really like to know if I got the sizing right. It looks like it, but I'm not certain. I also would like some advice on using different sizing operators (px vs. rem). I tried to be consistant here but there is some room for improvement.
Community feedback
- @kodan96Posted 5 months ago
hi there! ๐
You should avoid hard-coded values (pixels) most of the time. When you use these values you give up responsiveness(or you make it harder for yourself at least)..
Typically you will increase the font-size property with
@media
queries. If you have hard-coded values all over your CSS, you need to modify every element'sfont-size
. On the other hand, if you userem
-s all you need to do is changing thefont-size
in your CSS:root
selector and all your elements will have a new size based on that value.I usually use
em
forpadding and margin
for text-based elements, since their margin usually based on theirfont-size
, and again, when you change the font-size in:root
these values will scale up as well without you touching them, making your job easier and your page maintainable.If you are not familiar with the
:root
selector it's usually used to set custom properties(others call them CSS variables ) that you can apply later.Hope this was helpful ๐
Good luck and happy coding! ๐ช
Marked as helpful1
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