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

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.

主站蜘蛛池模板: 黄石市| 汝阳县| 勐海县| 阿尔山市| 沁源县| 武山县| 田东县| 准格尔旗| 乐都县| 莱西市| 左云县| 广宗县| 贵南县| 库伦旗| 泾源县| 大安市| 合作市| 小金县| 饶河县| 新丰县| 扶余县| 楚雄市| 丰原市| 铅山县| 陆河县| 唐海县| 泰来县| 景德镇市| 定陶县| 宜宾市| 新田县| 个旧市| 富蕴县| 新郑市| 郯城县| 茶陵县| 常德市| 三门峡市| 丰城市| 阿巴嘎旗| 盖州市|