Submitted about 2 years ago
Product Preview Card Component Challenge using Tailwind CSS
@fsuropaty
Design comparison
SolutionDesign
Solution retrospective
I'm struggling on how to change the picture depending on the screen size, Does using the <picture> tag is the best way to change the image or are there any better methods to do this task?
Thank You
Community feedback
- @freakyjonesPosted about 2 years ago
Hi, fsuropaty,
congratulation on completing the challenge.
There is two way you can handle image responsiveness
- use it as a background image as per your code it will be like
#image-section{ background-image:URL(image path); background-position:center; background-size:cover; background-repeat:no-repeat; }
My solution also uses this method.
- The second method will be when we make img take a width of 100% so that it can inherit the parent container responsive property. The code will be something like
#imagesection{ width: 10rem; } #imagesection img{ width:100% }
I hope this helps. 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