![](/img/trans.png)
[英]Why are the “srcset” and “sizes” attributes in the “img” element not working the way they should?
[英]why does sizes and srcset attributes of img tag not working?
我有一個帶有“尺寸”屬性的 img 標簽。
但我不知道為什么它不起作用
<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"
/>
我也認為“srcset”屬性不起作用。
為什么?
您需要通過屬性“srcset”而不是“src”來指定源文件。 srcset 和 sizes 屬性共同作用以創建響應式圖像。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.