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

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.

主站蜘蛛池模板: 昆山市| 巧家县| 兰西县| 海伦市| 土默特右旗| 福泉市| 金坛市| 安平县| 汉源县| 高平市| 广德县| 峨眉山市| 邓州市| 高淳县| 嫩江县| 罗江县| 兴安县| 舒城县| 安乡县| 叶城县| 九龙城区| 肇州县| 衢州市| 新宁县| 巫山县| 布拖县| 登封市| 阳江市| 怀柔区| 昭觉县| 陆丰市| 石林| 金沙县| 浪卡子县| 怀安县| 津南区| 南汇区| 鹿邑县| 沙雅县| 闻喜县| 曲水县|