如何让 srcset + 尺寸在 chrome 中工作?

时间:2021-01-20 19:36:10

标签: html responsive-images srcset

我试图弄清楚为什么 srcset 似乎没有根据我为我的尺寸属性定义的内容来切换图像。下面是标记。我在 Chrome 版本 87.0.4280.141 上运行它。我希望如果设备宽度小于 1024 像素以使用橙色图像 (https://cfvod.kaltura.com/p/1936311/sp/193631100/thumbnail/entry_id/1_qcusm08c/version/100001/width/382/height/215),如果设备宽度大于 1024 像素以使用苹果图像 (https://images.unsplash.com/photo-1568702846914-96b305d2aaeb?ixlib=rb-1.2.1&ixid=MXwxMjA3fDB8MHxleHBsb3JlLWZlZWR8MXx8fGVufDB8fHw%3D&w=1000&q=80)。

我只能看到苹果图片,即使在宽度小于 1024 像素的设备上也是如此。

<img 
  src="https://images.unsplash.com/photo-1568702846914-96b305d2aaeb?ixlib=rb-1.2.1&ixid=MXwxMjA3fDB8MHxleHBsb3JlLWZlZWR8MXx8fGVufDB8fHw%3D&w=1000&q=80" 
  srcset="https://images.unsplash.com/photo-1568702846914-96b305d2aaeb?ixlib=rb-1.2.1&ixid=MXwxMjA3fDB8MHxleHBsb3JlLWZlZWR8MXx8fGVufDB8fHw%3D&w=1000&q=80 595w, https://cfvod.kaltura.com/p/1936311/sp/193631100/thumbnail/entry_id/1_qcusm08c/version/100001/width/382/height/215 392w" 
  sizes="(max-width: 1024px) 392px, 595px" />

0 个答案:

没有答案
相关问题