Learn how to swap images at different screen width using custom Picture Tags and Attributes. This can be used to serve different image sizes, formats etc. to different screen sizes or browser preferences. Good thing is, only one image is loaded in the browser per time thereby reducing enormous network payload.
E.g code
<picture> <source media = "(min-width:650px)" srcset = "img_one.jpg"> <source media = "(min-width:465px)" srcset = "img_two.jpg"> <img src = "img_three.jpg"> </picture>
In the above code example, img_one.jpg will only show at a screen size above 650px, and img_two.jpg will show at a screen size above 465px but not beyond 650px. If any of these conditions are not met, then img_three.jpg will show.
See more details in video:
Share
Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how Design with Cracka is funded, why it matters, and how you can support us.
Subscribe
Login
0 Comments