While using img srcset with no css applied to the document, I can resize the browser width and the image width changes responsively so that the full image is always displayed (but smaller).
How can I make it so that it works like a standard image tag?
e.g. Resize browser window doesn't change image size...
<img src="http://lorempixel.com/400/200/"
srcset="http://lorempixel.com/160/200/ 160w,
http://lorempixel.com/320/200/ 320w,
http://lorempixel.com/640/200/ 640w,
http://lorempixel.com/1280/200/ 1280w">
You need sizes to make it responsive:
If you're going to make the img load the new source you need to refresh the page. As the browser pics the image on load.
same issue here srcset doesn't work when resizing screen, but picture + source are working
If you mean what I think you mean then this should help, put this with the CSS file and the images will resize with the page resize.
Use
x
descriptor instead ofw
descriptor, or specify the size you want in thesizes
attribute (which is required when usingw
).