官术网_书友最值得收藏!

Using responsive images and srcset to deliver high quality images on all screen sizes

To achieve the second goal, we can use layout="responsive" again, so that the thumbnails will scale for larger screens. The HTML for each item in the list now looks like this:

<li>
<figure class="related-thumb">
<amp-img src="img/penguin.jpg" width="125" height="75" layout="responsive"></amp-img>
<figcaption>
If a penguin can find a soul mate, I'm sure I can too
<span class="author">Rebekah Crane</span>
</figcaption>
</figure>
</li>
Thumbnails in 2x2 grid and with layout="responsive" scaling up on a larger screen (tablet device in portrait orientation)

There is a problem with this solution, however. It's the same problem that we had earlier when our main feature image was scaled up on large screens: it became pixelated. The same thing will happen with our thumbnails. Thankfully, we can apply the same solution as before using srcset:

<amp-img src="penguin.jpg" 
srcset="img/penguin-sm.jpg 125w,
img/penguin.jpg 640w"
width="125"
height="75"
layout="responsive"
</amp-img>

Now, on larger screens, the browser will automatically use the higher resolution image.

主站蜘蛛池模板: 高清| 威海市| 美姑县| 孟州市| 岱山县| 庆阳市| 临武县| 庆元县| 琼结县| 遂溪县| 珠海市| 西青区| 曲水县| 霞浦县| 积石山| 庐江县| 额敏县| 东源县| 游戏| 明溪县| 凤凰县| 崇州市| 繁峙县| 绥化市| 开江县| 额尔古纳市| 密山市| 洛阳市| 娱乐| 大丰市| 庆安县| 乌兰浩特市| 易门县| 合水县| 云龙县| 金阳县| 樟树市| 九寨沟县| 镇雄县| 勃利县| 珲春市|