【问题标题】:How do I position a YouTube iframe? [duplicate]如何定位 YouTube iframe? [复制]
【发布时间】:2019-09-26 18:44:02
【问题描述】:

我正在尝试使 YouTube 视频居中,但遇到了问题。这是代码。

 <div class="video">
<iframe width="560" height="315" align="middle" padding-bottom=0px left=40px src="https://www.youtube.com/embed/lHv3i9-2a0s" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
      </div>

您可以在下面的存储库中找到文件(html 和 css)。 https://github.com/t0091/bootstrap/tree/master/home

【问题讨论】:

  • width: 560px; margin: 0 auto; 放在#video div 上就可以了。
  • 如果我理解正确的话,我试过了。检查 CSS 文件的底部。

标签: html css iframe github-pages youtube-iframe-api


【解决方案1】:

您可以将 iframe 设置为

iframe{
  margin:0 auto;
  display:block;
}

iframe{
  margin:0 auto;
  display:block;
}
<div class="video">
<iframe width="560" height="315"  align="middle" padding-bottom=0px left=40px src="https://www.youtube.com/embed/lHv3i9-2a0s" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
      </div>

【讨论】:

    猜你喜欢
    • 2012-04-17
    • 1970-01-01
    • 2012-06-26
    • 1970-01-01
    • 2013-03-28
    • 2014-08-15
    • 2011-09-07
    • 2018-12-19
    • 1970-01-01
    相关资源
    最近更新 更多