麻烦制作高度响应youtube嵌入引导程序

时间:2014-07-25 07:37:08

标签: css twitter-bootstrap youtube responsive-design embed

我正在使用Bootstraps网格系统来创建一个响应式网站,该网站在容器中显示内容,从不超过查看高度,并使用三列显示宽度,除非通过小屏幕查看,在这种情况下是1列。问题是,我的youtube嵌入没有响应。我尝试将其设置为100%,auto,使用几个bootstrap类,从embed切换到iframe并尝试许多相同的想法。什么都行不通。无论宽度如何,我的静态高度约为100px。这是我的HTML。

<div class="row">
  <div class="col-md-4"><center>
    <h1>Once in a lifetime</h1>
    <p>
Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts. Separated they live in Bookmarksgrove right at the coast of the Semantics, a large language ocean. A small river named Duden flows by their place and supplies it with the necessary regelialia. It is a paradisematic country, in which roasted parts of sentences fly into your mouth. Even the all-powerful Pointing has no control about the blind texts it is an almost unorthographic life One day however a small line of blind text by the name of Lorem Ipsum decided to leave for the far World of Grammar. The Big Oxmox advised her not to do so, because there were thousands of bad Commas, wild Question Marks and devious Semikoli, but the Little Blind Text didn’t listen. She packed her seven versalia, put her initial into the belt and made herself on the way. When she reached the first hills of the Italic Mountains, she had a last view back on the skyline of her hometown Bookmarksg
    </p>
  </center></div>
  <div class="col-md-4"><center>

<embed width="80%" height="100%" src="//www.youtube.com/embed/NOcjwN3jkZ4?autoplay=1" frameborder="0" allowfullscreen></embed>

</center></div>
  <div class="col-md-4"><center>
    <h1>Check it out!</h1>
    <a href="http://wwww.link.xyz"><h3>http://wwww.link.xyz</h3></a>
  </center></div>
</div>

这里有一些用于防止水平滚动的CSS。

html, body {
  max-width: 100%;
  height:100%;
  overflow-x: hidden;
}

请帮忙。

1 个答案:

答案 0 :(得分:4)

使用下面的任何代码段,浏览器都可以通过创建在任何设备上正确缩放的内在比率,根据其包含块的宽度来确定视频尺寸。

<!-- 16:9 aspect ratio -->
<div class="embed-responsive embed-responsive-16by9">
  <iframe class="embed-responsive-item" src="//www.youtube.com/embed/NOcjwN3jkZ4?autoplay=1"></iframe>
</div>

<!-- 4:3 aspect ratio -->
<div class="embed-responsive embed-responsive-4by3">
  <iframe class="embed-responsive-item" src="//www.youtube.com/embed/NOcjwN3jkZ4?autoplay=1"></iframe>
</div>

您可能需要查看bootstrap文档以获取有关此

的更多信息

http://getbootstrap.com/components/