具有固定高度的 AMP 轮播不起作用
AMP carousel with fixed-height does not work
昨天参加了AMP团队的精彩路演后,我开始对网页进行AMPlify。如果我使用 layout="responsive",轮播将完美运行。但是,如果我使用 layout="fixed-height",图像不会显示,只有导航按钮在那里。以下内容来自页面来源:
<amp-carousel width="450" height="300" layout="fixed-height" type="slides" class="i-amphtml-element i-amphtml-carousel-has-controls i-amphtml-slidescroll">
<!-- Use `type="slides"` to display a list of images as slides. -->
<div class="i-amphtml-slides-container" aria-live="polite">
<div class="i-amphtml-slide-item">
<amp-img alt="ART" height="300" width="450" src="/Content/images/foo_01.png" layout="responsive" class="i-amphtml-element i-amphtml-layout-responsive i-amphtml-layout-size-defined amp-carousel-slide">
<i-amphtml-sizer style="display: block; padding-top: 66.6667%;"></i-amphtml-sizer>
</amp-img>
</div>
<div class="i-amphtml-slide-item">
<amp-img alt="ART" height="300" width="450" src="/Content/images/foo_02.png" layout="responsive" class="i-amphtml-element i-amphtml-layout-responsive i-amphtml-layout-size-defined amp-carousel-slide">
<i-amphtml-sizer style="display: block; padding-top: 66.6667%;"></i-amphtml-sizer>
</amp-img>
</div>
<div class="i-amphtml-slide-item">
<amp-img alt="ART" height="300" width="450" src="/Content/images/foo_03.png" layout="responsive" class="i-amphtml-element i-amphtml-layout-responsive i-amphtml-layout-size-defined amp-carousel-slide">
<i-amphtml-sizer style="display: block; padding-top: 66.6667%;"></i-amphtml-sizer>
</amp-img>
</div>
<div class="i-amphtml-slide-item">
<amp-img alt="ART" height="300" width="450" src="/Content/images/foo_04.png" layout="responsive" class="i-amphtml-element i-amphtml-layout-responsive i-amphtml-layout-size-defined amp-carousel-slide">
<i-amphtml-sizer style="display: block; padding-top: 66.6667%;"></i-amphtml-sizer>
</amp-img>
</div>
<div class="i-amphtml-slide-item">
<amp-img alt="ART" height="300" width="450" src="/Content/images/foo_05.png" layout="responsive" class="i-amphtml-element i-amphtml-layout-responsive i-amphtml-layout-size-defined amp-carousel-slide">
<i-amphtml-sizer style="display: block; padding-top: 66.6667%;"></i-amphtml-sizer>
</amp-img>
</div>
<div class="i-amphtml-slide-item">
<amp-img alt="ART" height="300" width="450" src="/Content/images/foo_06.png" layout="responsive" class="i-amphtml-element i-amphtml-layout-responsive i-amphtml-layout-size-defined amp-carousel-slide">
<i-amphtml-sizer style="display: block; padding-top: 66.6667%;"></i-amphtml-sizer>
</amp-img>
</div>
</div>
<div tabindex="0" class="amp-carousel-button amp-carousel-button-prev amp-disabled" role="button" aria-disabled="true"></div>
<div tabindex="0" class="amp-carousel-button amp-carousel-button-next" role="button" aria-disabled="false"></div>
</amp-carousel>
任何提示将不胜感激。
固定高度布局类型不接受定义的宽度。从您的 amp-carousel 标签中删除宽度或将值更改为 auto。
您可以详细了解不同的布局属性 here。
昨天参加了AMP团队的精彩路演后,我开始对网页进行AMPlify。如果我使用 layout="responsive",轮播将完美运行。但是,如果我使用 layout="fixed-height",图像不会显示,只有导航按钮在那里。以下内容来自页面来源:
<amp-carousel width="450" height="300" layout="fixed-height" type="slides" class="i-amphtml-element i-amphtml-carousel-has-controls i-amphtml-slidescroll">
<!-- Use `type="slides"` to display a list of images as slides. -->
<div class="i-amphtml-slides-container" aria-live="polite">
<div class="i-amphtml-slide-item">
<amp-img alt="ART" height="300" width="450" src="/Content/images/foo_01.png" layout="responsive" class="i-amphtml-element i-amphtml-layout-responsive i-amphtml-layout-size-defined amp-carousel-slide">
<i-amphtml-sizer style="display: block; padding-top: 66.6667%;"></i-amphtml-sizer>
</amp-img>
</div>
<div class="i-amphtml-slide-item">
<amp-img alt="ART" height="300" width="450" src="/Content/images/foo_02.png" layout="responsive" class="i-amphtml-element i-amphtml-layout-responsive i-amphtml-layout-size-defined amp-carousel-slide">
<i-amphtml-sizer style="display: block; padding-top: 66.6667%;"></i-amphtml-sizer>
</amp-img>
</div>
<div class="i-amphtml-slide-item">
<amp-img alt="ART" height="300" width="450" src="/Content/images/foo_03.png" layout="responsive" class="i-amphtml-element i-amphtml-layout-responsive i-amphtml-layout-size-defined amp-carousel-slide">
<i-amphtml-sizer style="display: block; padding-top: 66.6667%;"></i-amphtml-sizer>
</amp-img>
</div>
<div class="i-amphtml-slide-item">
<amp-img alt="ART" height="300" width="450" src="/Content/images/foo_04.png" layout="responsive" class="i-amphtml-element i-amphtml-layout-responsive i-amphtml-layout-size-defined amp-carousel-slide">
<i-amphtml-sizer style="display: block; padding-top: 66.6667%;"></i-amphtml-sizer>
</amp-img>
</div>
<div class="i-amphtml-slide-item">
<amp-img alt="ART" height="300" width="450" src="/Content/images/foo_05.png" layout="responsive" class="i-amphtml-element i-amphtml-layout-responsive i-amphtml-layout-size-defined amp-carousel-slide">
<i-amphtml-sizer style="display: block; padding-top: 66.6667%;"></i-amphtml-sizer>
</amp-img>
</div>
<div class="i-amphtml-slide-item">
<amp-img alt="ART" height="300" width="450" src="/Content/images/foo_06.png" layout="responsive" class="i-amphtml-element i-amphtml-layout-responsive i-amphtml-layout-size-defined amp-carousel-slide">
<i-amphtml-sizer style="display: block; padding-top: 66.6667%;"></i-amphtml-sizer>
</amp-img>
</div>
</div>
<div tabindex="0" class="amp-carousel-button amp-carousel-button-prev amp-disabled" role="button" aria-disabled="true"></div>
<div tabindex="0" class="amp-carousel-button amp-carousel-button-next" role="button" aria-disabled="false"></div>
</amp-carousel>
任何提示将不胜感激。
固定高度布局类型不接受定义的宽度。从您的 amp-carousel 标签中删除宽度或将值更改为 auto。
您可以详细了解不同的布局属性 here。