Product preview card component using Tailwindcss and NextJS and React
Design comparison
Solution retrospective
Share with me how to modify an image's url based on the size of the display?
Community feedback
- @karthik2265Posted over 2 years ago
Hey debjit, well done
The app looks nice.
To modify the URL of an image, you can use JavaScript to do it. There is a method called window.matchMedia(query) which takes a media query like '(max-width: 600px)' as a string and returns object which contains information, the most important key in the object is matches which is a boolean value specifying if the query is satisfied or not.
Check this out: https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia
Thank You
Marked as helpful0@debjitPosted over 2 years ago@karthik2265 I appreciate your response. I only wanted to use CSS and Tailwind for this. I'm using Next, which has built-in image optimization.
1 - @The43rdsenseiPosted over 2 years ago
good one bro
you can also add two different image in your html and toggle display based on the screen you want individual image to appear
0@debjitPosted over 2 years ago@The43rdsensei I appreciate your response. I only wanted to use CSS and Tailwind for this. I'm using Next, which has built-in image optimization.
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