在div中制作iframe响应

时间:2018-02-23 04:50:40

标签: html css bootstrap-4

我正在尝试让iframe对所有屏幕都有响应。

  <div class="iframe-class">
    <iframe src="https://www.youtube.com/embed/PZEwPJzMKGg"></iframe>
  </div>

3 个答案:

答案 0 :(得分:1)

使用Bootstrap 3.2,您可以将每个iframe包装在您选择的response-embed包装中:

http://getbootstrap.com/components/#responsive-embed

<!-- 16:9 aspect ratio -->
<div class="embed-responsive embed-responsive-16by9">
  <iframe class="embed-responsive-item" src="…"></iframe>
</div>

<!-- 4:3 aspect ratio -->
<div class="embed-responsive embed-responsive-4by3">
  <iframe class="embed-responsive-item" src="…"></iframe>
</div>

参考: Responsive iframe using Bootstrap

答案 1 :(得分:1)

试试这个:

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

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

答案 2 :(得分:0)

使iframe对所有屏幕都有响应

这对你肯定有用。

<div class="embed-responsive embed-responsive-16by9">
    <iframe class="embed-responsive-item" src="https://www.youtube.com/embed/PZEwPJzMKGg"></iframe>
  </div>

Refrence Link