【问题标题】:Trouble making height responsive youtube embed with bootstrap使用引导程序嵌入高度响应 youtube 时遇到问题
【发布时间】:2014-09-16 23:52:50
【问题描述】:

我正在使用 Bootstraps 网格系统来创建一个响应式站点,该站点在容器中显示内容,从不超过查看高度,并使用三列显示宽度,除非通过小屏幕查看,在这种情况下为 1 列。问题是,我的 youtube 嵌入没有响应。我尝试将其设置为 100%,自动,使用几个引导类,从嵌入切换到 iframe,并尝试了许多相同的想法。没有任何工作。无论宽度如何,我最终都会得到一个大约 100 像素的小静态高度。这是我的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;
}

请帮忙。

【问题讨论】:

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


【解决方案1】:

使用下面的任何 sn-ps 将允许浏览器通过创建可在任何设备上正确缩放的固有比率来根据其包含块的宽度确定视频尺寸。

<!-- 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>

您可能需要查看引导文档以获取更多信息

http://getbootstrap.com/components/

【讨论】:

    猜你喜欢
    • 2016-11-24
    • 1970-01-01
    • 2019-11-12
    • 1970-01-01
    • 2018-09-10
    • 1970-01-01
    • 2019-12-22
    • 2018-02-08
    • 2011-09-04
    相关资源
    最近更新 更多