Product preview card component using Flexbox (Responsive)
Design comparison
Solution retrospective
It's my first ever Challenge Project that I completed with Responsive Design. Responsiveness was the thing that took me a while as I've applied Media Queries in my project for the first time on my own. I watched tutorials and used Media Queries earlier but wasn't comfortable until I made my hands dirty with Media Queries on my own.
Community feedback
- @andreimaierPosted over 1 year ago
Congratulations on completing the challenge! You're right that you only learn by doing it yourself! Keep up the good work!
Marked as helpful2 - @jonatasolmartinsPosted over 1 year ago
Congrats man! Feel tips, you can the picture element and change the image based on the media query.
<picture> <source srcset="/images/image-product-desktop.jpg" media="(min-width: 600px)" /> <img src="/images/image-product-mobile.jpg" alt="perfume ilustrasion"> </picture>
In the example above the mobile image will be used until the screen get bigger than 600px and then the image is replaced with the image in the source element.
The last tip is to use the before or after pseudo classes to place a svg image on a element.
<button class="add-to-cart">Add to Cart</button>
And then in the css file
button::before { content: url(/images/icon-cart.svg); }
Before means that it will place a content (SVG image in this case) before the first child of the element (my text in this case) The result will be same as if I had put my SVG file/tag in my html but it makes my html more cleaner cause SVG tends to be very big.
My last tip is to look at someone else code after you finished your to get more insights on how to make things better, I do that and learn lots things that I can apply in my next challenge.
Congrats again and happy code!
Marked as helpful1@git-riteshPosted over 1 year agoThank you so much for reviewing my code and giving these awesome tips!@jonatasolmartins i'm gonna use it right away! i'll remember your words "look after someone else's code for more insights" Thanks Again : )
0@git-riteshPosted over 1 year agoThis isn't working for me.
<source srcset="/images/image-product-desktop.jpg" media="(min-width: 600px)" /> <img src="/images/image-product-mobile.jpg" alt="perfume ilustrasion"> </picture>
Instead of this added both the images inside the
<picture>
element. And for the Mobile Design i setdisplay:none;
to Desktop image & vice-versa for the Desktop Design. @jonatasolmartins0
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