我得到了以下代码:
<picture>
<source media="(min-width: 960px)" srcset="http://placehold.it/960x150">
<source media="(min-width: 575px)" srcset="http://placehold.it/575x150">
<img src="" alt="">
</picture>
加载页面时,img src 会自动替换为第一个匹配的源元素。 有没有办法在页面第一次加载时阻止这种自动替换?我想到了类似附加 html 属性的东西。
最佳答案
你在哪个浏览器上测试?
<picture>
<source media="(min-width: 960px)" srcset="http://placehold.it/960x150">
<source media="(min-width: 575px)" srcset="http://placehold.it/575x150">
<img src="" alt="">
</picture>
This seems to work fine on Chrome . The picture feature has not got full support , 所以这可能是问题所在
关于html - 防止图片源自动加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33038198/