简体   繁体   English

为什么 img 标签的大小和 srcset 属性不起作用?

[英]why does sizes and srcset attributes of img tag not working?

I have an img tag with the attribute of "sizes".我有一个带有“尺寸”属性的 img 标签。
but I don't know why it doesn't work但我不知道为什么它不起作用

<img
  src="photo/gallery/tezos.jpg"
  alt=""
  srcset="photo/photo gallery/tezos@1x.jpg 1x,
  photo/photo gallery/tezos@2x.jpg 2x,
  photo/photo gallery/tezos@3x.jpg 3x"
  sizes="
  (max-width:600px) 100vw, (max-width:900px) 50vw, 33vw"
/>

also I think the "srcset" attribute doesn't work.我也认为“srcset”属性不起作用。
why?为什么?

You need to specify the source file by the attribute "srcset" not the "src".您需要通过属性“srcset”而不是“src”来指定源文件。 The srcset and sizes attributes work together to create responsive images. srcset 和 sizes 属性共同作用以创建响应式图像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM