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

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.

主站蜘蛛池模板: 平度市| 二手房| 泸溪县| 明溪县| 宁化县| 武陟县| 宁都县| 同心县| 龙井市| 三台县| 房产| 天长市| 万宁市| 保山市| 荣昌县| 沿河| 榆树市| 乐安县| 揭西县| 疏勒县| 闵行区| 琼中| 康保县| 星座| 永登县| 丰顺县| 宁国市| 漳浦县| 太仓市| 裕民县| 昭通市| 安福县| 肥东县| 天气| 霍山县| 陕西省| 夏河县| 邓州市| 丹巴县| 泾阳县| 客服|