【问题标题】:<picture> element and srcset<picture> 元素和 srcset
【发布时间】:2020-03-13 20:58:15
【问题描述】:

比起srcset,我更喜欢使用&lt;picture&gt; 元素,因为我可以使用WebP 并回退到JPG。我不能用srcset 做到这一点,这很遗憾。

但是,我更喜欢srcset,因为它能够通过分辨率更改图像,例如2 倍,3 倍

  1. 有没有办法将这两个选项结合起来,让我可以两全其美。
  2. 为什么我不能使用 srcset 进行艺术指导,因为这通常被用作使用 &lt;picture&gt; 的主要原因,但我不明白为什么我不能使用 srcset 做到这一点。李>

【问题讨论】:

    标签: image srcset


    【解决方案1】:

    实际上,您可以将 srcset 与图片元素结合使用,并同时使用这两个功能

    <picture>
      <source 
        media="(min-width: 650px)" 
        srcset="images/kitten-stretching.png,
                images/kitten-stretching@1.5x.png 1.5x,  
                images/kitten-stretching@2x.png 2x">
    </picture>
    

    我仍然不知道您为什么不使用 srcset 来进行艺术指导。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-08-29
      • 1970-01-01
      • 1970-01-01
      • 2020-11-22
      • 1970-01-01
      • 2012-10-05
      • 2017-02-23
      相关资源
      最近更新 更多