【问题标题】:Html video display - incorrect size?Html 视频显示 - 尺寸不正确?
【发布时间】:2015-08-09 02:43:48
【问题描述】:

我正在尝试将 YouTube 视频嵌入到带有 iframe 的 HTML 页面中。我有疑问(尺寸不对)。视频链接:https://www.youtube.com/watch?v=EqQ6gy-tT9Y?autoplay=1

我的html代码:

<section id="test">
  <div style="text-align: center;">
    <iframe src="https://www.youtube.com/watch?v=EqQ6gy-tT9Y?
                autoplay=1" width="420" height="315"  align="center">
      <p>Your browser does not support iframes.</p>
    </iframe>
  </div>
</section>

【问题讨论】:

    标签: html iframe src


    【解决方案1】:

    您应该已经从 youtube 复制了嵌入代码:

    <iframe width="560" height="315" src="https://www.youtube.com/embed/EqQ6gy-tT9Y?autoplay=1" frameborder="0" allowfullscreen></iframe>
    

    注意链接是:

    https://www.youtube.com/embed/EqQ6gy-tT9Y

    而不是

    https://www.youtube.com/watch?v=EqQ6gy-tT9Y

    你的代码应该是:

    <section id="test">
                    <div style="text-align: center;">
                    <iframe src="https://www.youtube.com/embed/EqQ6gy-tT9Y?autoplay=1" width="420" height="315"  align="center">
                        <p>Your browser does not support iframes.</p>
                    </iframe>
    
                    </div>
      </section>
    

    顺便说一句:您在 &lt;iframe src=""&gt; 属性中有换行符,我不知道您是否只是为了可读性而这样做,但它会导致问题,请将换行符保留在 html 元素属性之外

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-06-30
      • 1970-01-01
      • 1970-01-01
      • 2019-10-18
      • 2013-06-27
      • 1970-01-01
      • 2015-04-05
      • 1970-01-01
      相关资源
      最近更新 更多