Responsive Product Preview Card Component with HTML,CSS

Solution retrospective
This was pretty easy to build
I have a question tho, apart from setting a flex-basis on the container to display the image and its contents side by side. Are there any other ways to set them side by side
I am open to any feedback on how I can improve and reduce unnecessary code.
Please log in to post a comment
Log in with GitHubCommunity feedback
- @Yasmine10
Hi @cacti00
An easy way to display your image and content side by side is to use grid, you could do something like this in your
.product-card
class:display: grid; grid-template-columns: repeat(2, 1fr); /* use grid-template-columns: 1fr; for mobile view */
I also saw that you're using divs with an img inside to display the image in your html. There is an html element for that actually: '<picture>'
Here's an example of what that would look like for this project:
<picture> <source srcset="images/image-product-desktop.jpg" media="(min-width: 50em)" /> <img src="images/image-product-mobile.jpg" alt="" /> </picture>
Hope this is helpful 😊
Marked as helpful - @bccpadge
Hello @cacti00. Congratulations on completing this challenge 🎉 !!
To answer your question you can use CSS Grid
More info on CSS Grid📚
Here is my solution to this challenge
I followed Kevin Powell's YouTube tutorial on the Product Preview Component and he explains how to use the picture tag to change the images as well.
More info on HTML Picture Tag📚
Hopes this helps you and don't hesitate to reach out to me if you have any questions ✌🏼
Marked as helpful
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