【问题标题】:Can I use amp-video-container with amp-video in amp-story even if I am not using amp-carousel? What does amp-video-container do?即使我不使用 amp-carousel,是否可以在 amp-story 中使用 amp-video-container 和 amp-video? amp-video-container 有什么作用?
【发布时间】:2018-10-14 03:44:11
【问题描述】:

是否有关于 amp-video-container 的详细文档?我正在尝试了解如何在 amp-story 中使用 amp-video-container 以确保我的视频不会被截断并且可以完整观看。

https://ampbyexample.com/advanced/video_carousels_with_amp-carousel/

  <div>
    <div class="amp-video-container">
      <amp-reach-player class="amp-video"
        data-embed-id="default"
        layout="responsive"
        width="560"
        height="315">
      </amp-reach-player>
    </div>
  </div>

另外,使用 amp-video-container 时是否需要包含此脚本标签?

<script async custom-element="amp-carousel" src="https://cdn.ampproject.org/v0/amp-carousel-0.1.js"></script>

【问题讨论】:

    标签: video amp-html amp-story


    【解决方案1】:

    如果要显示完整视频,可以使用 CSS:

    amp-video video {
      object-fit: contain;
    }
    

    在您提供的代码 sn-p 中,amp-video-container 没有什么特别之处;它只是一个 CSS 类名。你不需要任何额外的脚本来使用这个 CSS,这与 amp-carousel 无关。

    【讨论】:

    • 我添加了 object-fit: 包含。视频仍然没有填满整个页面。
    • 为什么参考页面会列出“amp-video-container”类而不显示 CSS? (xbyexample.appspot.com/advanced/…)
    • 您可以通过查看that sample in the AMP by Example playground(通过单击您链接的页面中的铅笔图标访问)查看所有代码,包括 CSS。
    • 谢谢。我看到 .amp-video-container { display: flex;弹性流:列;证明内容:中心;高度:100%; } .amp-video { 宽度:100%;高度:55%; }
    • 即使使用这个 css,视频也不会填满屏幕。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多