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

Building an expandable top stories category list

Let's build out the AMP-HTML first. There will be a section for each of our main categories. The category name will be the header in each section, and we'll then add some top stories as li list items as the content for each section. We can reuse the thumbnail and text layout we developed for the related content examples in the last chapter. The AMP-HTML code will look like this:

<amp-accordion>
<section>
<h3>news</h3>
<ul>
<li>News story 1 content</li>
<li>News story 2 content</li>
...
</ul>
</section>
<section>
<h3>sports</h3>
<ul>
<li>Sports story 1 content</li>
<li>Sports story 2 content</li>
...
</ul>
</section>
...
</amp-accordion>

Recall from the last chapter our related content items that included an image and caption. Let's reuse that now. So, each section of the amp-accordion will look something like this:

<section>
<h3 class="category-title">news</h3>
<ul>
<li>
<figure class="related-thumb">
<amp-img media = "(min-width: 35.01rem)"
src = "img/penguin.jpg"
...
</amp-img>
...
<figcaption>News story 1 content</figcaption>
</figure>
</li>
...

The markup is too long to show here, but you can see the full code for this example at /ch4/accordion-2.html.

主站蜘蛛池模板: 澄江县| 丰台区| 津南区| 梨树县| 五华县| 安福县| 万全县| 南丹县| 望都县| 于田县| 宁武县| 资源县| 元朗区| 泉州市| 铜川市| 永和县| 珲春市| 民权县| 临夏市| 固阳县| 和平区| 和龙市| 涞源县| 白沙| 凤城市| 商都县| 桂阳县| 资源县| 平潭县| 富裕县| 阿克陶县| 繁峙县| 伊宁县| 内黄县| 盘山县| 新闻| 佛坪县| 澄迈县| 车险| 许昌市| 淮北市|