【问题标题】:Embed Vimeo Video in full width以全宽嵌入 Vimeo 视频
【发布时间】:2017-05-27 14:50:09
【问题描述】:

我在我的网站上嵌入了一个 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-video。

但是,原始视频的宽度仅为 640 像素。我希望始终以 100% 的宽度显示视频,无论视频的某些内容是否是因为 600 像素的高度,但重要的是它显示为全宽。

有人提示我如何实现这一目标吗? 谢谢!

【问题讨论】:

  • 您可以将嵌入标签编辑到帖子中吗?

标签: html css video vimeo


【解决方案1】:

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

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

【讨论】:

    【解决方案2】:

    我认为您正在寻找的是vw(视口宽度)。 width:100% 表示父级的 100% 宽度。 width: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;
    }
    

    【讨论】:

    • 但后来发生了这种情况:d.pr/i/7egC我的视频周围仍然有一个黑色的空白区域...
    • 尝试将width:100vw添加到#fys-fp-video
    猜你喜欢
    • 2016-06-04
    • 2015-10-21
    • 1970-01-01
    • 2017-04-05
    • 2020-09-22
    • 2014-04-04
    • 1970-01-01
    • 2020-05-26
    • 2012-09-05
    相关资源
    最近更新 更多