根据我对<amp-carousel>的了解,它只有两种类型的旋转木马接口:carousel和slides,你可以在AMP示例网站上看到。我需要创建像这样的东西,多列旋转木马。AMP carousel能够做到这一点吗?

发布于 2017-09-15 12:47:50
在某种程度上,是的。您可以使用slide接口,在每个部分下,但4个条目。
<amp-carousel height="300" layout="fixed-height" type="slides">
<div>
<div class="blue-box"> 1 </div>
<div class="red-box"> 2 </div>
<div class="green-box"> 3 </div>
<div class="yellow-box"> 4 </div>
</div>
<div>
<div class="blue-box"> 9 </div>
<div class="red-box"> 8 </div>
<div class="green-box"> 7 </div>
<div class="yellow-box"> 6 </div>
</div>
</amp-carousel>我知道它不会一次只移动一个条目,但我想它会接近你想要的
发布于 2020-09-09 20:03:16
你不能随心所欲地定制amp-carousel,你需要查看amp-base-carousel,它允许你设置visible-count、advance-count和其他有用的属性。
示例:
<amp-base-carousel
loop="true"
height="450"
layout="fixed-height"
visible-count="(min-width: 1150px) 3, (min-width: 700px) 2, 1"
advance-count="(min-width: 1150px) 3, (min-width: 700px) 2, 1"
>
<div>slide1</div>
<div>slide2</div>
<div>slide3</div>
<div>slide4</div>
<button slot="next-arrow" class="carousel-next" aria-label="Next">
<i class="fas fa-chevron-circle-right"></i>
</button>
<button slot="prev-arrow" class="carousel-prev" aria-label="Previous">
<i class="fas fa-chevron-circle-left"></i>
</button>
</amp-base-carousel>为按钮添加一些样式:
.carousel-prev, .carousel-next {
filter: drop-shadow(0px 1px 2px #4a4a4a);
width: 40px;
height: 40px;
padding: 20px;
background-color: transparent;
border: none;
outline: none;
font-size: 24px;
opacity:0.7;
}https://stackoverflow.com/questions/46213545
复制相似问题