如何在AMP中显示轮播点?

时间:2016-07-02 17:35:29

标签: carousel show amp-html

在这个轮播中, 我该如何显示点?

<amp-carousel layout=fixed-height height=400 type=slides autoplay controls loop arrows dots='.'>
  <amp-img src="img/slaid.jpg" layout=fixed-height height=400></amp-img>
  <amp-img src="img/slaid.jpg" layout=fixed-height height=400></amp-img>
</amp-carousel>

2 个答案:

答案 0 :(得分:0)

可以通过在CSS自定义属性<style></style>中指示导航点来添加导航点。这是来自Styling/Theming with AMP的Github示例:

<head>
  <style>
    amp-carousel {
      --arrow-color: green;
      --dots: {
        opacity: 50%;
        color: blue;
      }
    }
  </style>
</head>

<body>
  <amp-carousel width=500 height=500>
    <div>
      <amp-img width=500 height=500 src="https://placekitten.com/g/500/500">
      </amp-img>
    </div>
    <div>
      <amp-img width=500 height=500 src="https://placekitten.com/g/500/500">
      </amp-img>
    </div>
  </amp-carousel>
</body>

您还可以查看此SO thread以获取其他参考资料。

答案 1 :(得分:0)

此代码实验室中有一个示例: https://codelabs.developers.google.com/codelabs/advanced-interactivity-in-amp/index.html

最终代码在这里:

<amp-carousel type="slides" layout="fixed-height" height=250 id="carousel" on="slideChange:AMP.setState({selected: {slide: event.index}})">
  <amp-img width=200 height=250 src="./shirts/black.jpg" [src]="shirts[selected.sku].image"></amp-img>
  <amp-img width=300 height=375 src="./shirts/black.jpg" [src]="shirts[selected.sku].image"></amp-img>
  <amp-img width=400 height=500 src="./shirts/black.jpg" [src]="shirts[selected.sku].image"></amp-img>
</amp-carousel>
<p class="dots">
  <span [class]="selected.slide == 0 ? 'current' : ''" class="current"></span>
  <span [class]="selected.slide == 1 ? 'current' : ''"></span>
  <span [class]="selected.slide == 2 ? 'current' : ''"></span>
</p>

https://github.com/googlecodelabs/advanced-interactivity-in-amp/blob/master/static/final.html