提问者:小点点

全宽度嵌入Vimeo视频


我在我的网站上嵌入了vimeo视频,如下所示:

<div class="fys-fp-content-wrapper">
<div id="fys-fp-video">
</div>
</div>

#fys-fp-video {
    position: relative;
    padding-bottom: 56.25%;
    padding-top: 25px;
    height: 600px;
}
#fys-fp-video iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 600px;
}

Vimeo iFrame加载到#fys fp视频中。

然而,原始视频的宽度只有640px。我希望始终以100%的宽度显示视频,不管视频中的某些内容是否是由于600px的高度,但重要的是显示全宽。

有人能告诉我怎么才能做到吗?谢谢


共2个答案

匿名用户

如果你使用引导,很容易:

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

资料来源:https://getbootstrap.com/docs/4.0/utilities/embed/

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" />

<div class="embed-responsive embed-responsive-16by9">
  <iframe lass="embed-responsive-item" src="https://player.vimeo.com/video/54596361" frameborder="0" allow="autoplay; fullscreen" allowfullscreen></iframe>
</div>

匿名用户

我想你要找的是vw(视口宽度)<代码>宽度:100%表示父级的100%宽度<代码>宽度:100vw表示屏幕的100%。我建议你这样做:

#fys-fp-video {
    position: relative;
    padding-bottom: 56.25%;
    padding-top: 25px;
    height: 600px;
}
#fys-fp-video iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 600px;
}