我刚刚开始一个新的网页,所以没有太多标记。
我将其设置为:
<picture>
<source media="(min-width: 1000px)"
srcset="images/largeme.jpg">
<source media="(min-width: 465px)"
srcset="images/medme.jpg">
<img src="images/smallme.jpg"alt="hero profile">
</picture>
无论窗口的宽度如何,它默认为medme.jpg图片。我设置了这个:
<picture>
<source media="(min-width: 1000px)"
srcset="images/largeme.jpg">
<source media="(min-width: 465px)"
srcset="images/medme.jpg">
<!-- <img src="images/smallme.jpg"alt="hero profile">-->
</picture>
注释掉img后备标记,它什么也不显示。
我正在运行应支持图片元素的Chrome 52。但是它似乎表现得好像不支持它一样。我在这里做错了什么?
最佳答案
img
元素内的picture
元素不是可选的。 picture
包装器及其source
元素可用来更改img
,而不是替换它。