@getlinas
Posted
Hey man, nicely done!
I've noticed that you're still using desktop image for mobile version of design. I don't have much experience yet and not sure about best practices, but I've recently learned a neat trick that seemed to be worth trying here (because of 2 different images that Frontend Mentor provided with files).
You also also check my code, I've just submitted same exercise. In short, I've used <picture> tag in HTML to set 2 different images depending on media rules. Here is that part of code, you might want to check that out:
<picture>
<source media="(max-width: 799px)" srcset="images/image-product-mobile.jpg">
<source media="(min-width: 800px)" srcset="images/image-product-desktop.jpg">
<img class="image" src="images/image-product-mobile.jpg" alt="">
</picture>
Good luck!
Marked as helpful
@sliyarli
Posted
Hey there, @getlinas! :)
that's a really interesting use of code! I didn't know we could use the picture tag like this!
Thanks for reaching out and sharing your approach to handling different images for desktop and mobile versions. Your use of the <picture> tag with the <source> elements and media queries is indeed a great way to ensure that the appropriate image is displayed based on the user's device.
In your example, you've provided a solution that swaps out images smoothly based on screen size. This can be particularly helpful in optimizing the loading time and user experience for different devices.
Regarding your approach of using a single image and zooming it for the mobile design using the background-image property, that's a creative way to handle the situation without using JavaScript. By adjusting the background positioning and possibly using background size, you can achieve the desired effect. This can also help reduce the number of image files that need to be loaded, which can contribute to faster page loading times.
It's great to see that you're thinking about different solutions and considering factors like image loading and responsiveness. Keep up the good work in your front-end development journey! If you have any more questions or want to discuss further, feel free to ask. Good luck with your coding projects! :)