Reputation: 2991
I am trying to use the <picture>
and <source>
elements to provide some responsive images for my site.
My problem is that only the default image shows. I have tried reloading the page using different window sizes and I have also loaded PictureFill.
What am I doing wrong?
<picture>
<!--[if IE 9]><video style="display: none;"><![endif]-->
<source media="(max-width: 479px)" srcset="smallImage.jpg" />
<source media="(max-width: 640px)" srcset="mediumImage.jpg" />
<source media="(max-width: 767px)" srcset="largeImage.jpg" />
<!--[if IE 9]></video><![endif]-->
<img class="rsImg" src="xLargeImg.jpg" alt="MyDefaultImg" />
</picture>
NB: I have been using Chrome while getting this issue
Upvotes: 0
Views: 45
Reputation: 548
I would try this:
<picture>
<!--[if IE 9]><video style="display: none;"><![endif]-->
<source media="(min-width: 767px)" srcset="xLargeImg.jpg" /> <!-- the default image is also stated as a source -->
<source media="(max-width: 767px)" srcset="largeImage.jpg" />
<source media="(max-width: 640px)" srcset="mediumImage.jpg" />
<source media="(max-width: 479px)" srcset="smallImage.jpg" />
<!--[if IE 9]></video><![endif]-->
<img class="rsImg" srcset="xLargeImg.jpg" alt="MyDefaultImg" />
</picture>
Upvotes: 0