【问题标题】:Can I use srcset attribute in css to edit resolution?我可以在 css 中使用 srcset 属性来编辑分辨率吗?
【发布时间】:2015-04-14 15:35:52
【问题描述】:

我想知道是否可以以某种方式使用 css 中的 srcset 属性来(例如)使所有图像变为 2x,它通常像这样工作

<img src="image.jpg" srcset="image.jpg 1x, higher-resolution-image.jpg 2x" >

我想知道是否有办法在 css 中使用它来使所有图像以 2x 显示 在此先感谢:D

【问题讨论】:

标签: html css srcset


【解决方案1】:

你应该会发现这篇文章很有用:

Is there a srcset equivalent for css background image

它提到使用图像集:

background: -webkit-image-set( url('path/to/image') 1x, url('path/to/high-res-image') 2x );

【讨论】:

  • 您应该使用标志来指出重复的问题,而不是链接到问题并在此处复制答案。
  • 好点,但我只是认为问题是针对“所有图像”的,可能需要另一种解决方案,也许默认情况下会影响所有图像。
  • @ShastriH:甚至没有使用“分享”链接;-)。顺便说一句,-webkit-image-set 可以去任何需要图像的地方,而不仅仅是background,所以它应该涵盖所有(Webkit)基础。
猜你喜欢
  • 2014-02-06
  • 2022-01-15
  • 2014-03-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-12-01
  • 1970-01-01
相关资源
最近更新 更多