Responsive Product Preview Card Component with HTML,CSS
Design comparison
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.
Community feedback
- @Yasmine10Posted over 1 year ago
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 helpful3 - @bccpadgePosted over 1 year ago
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 helpful1@cacti00Posted over 1 year agoI saw Kevinβs tutorial on this challenge but I just decided to do it myself to see the areas I lack in css.
With the resources you just provided Iβm sure I will be using grid more often Thanks @bccpadge
0
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