如何定位YouTube iframe?

时间:2019-05-09 00:56:34

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

我正在尝试将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

1 个答案:

答案 0 :(得分: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>

相关问题