Vimeo 全宽
Vimeo full width
我正在尝试在网页中以全宽显示一个 vimeo 视频。
这是现在的样子:
如您所见,黑色是全宽但不是视频。它应该是全角的,不显示控件,自动播放和循环播放。
我的代码现在看起来像这样:
<iframe src="https://player.vimeo.com/video/208176323?autoplay=1&loop=1&background=1" width="100%" height="500px" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
客户端有vimeo plus但没有vimeo pro。谁能帮我解决这个问题。
更新:
我已将我的代码更改为:
<style>
.embed-container {
position: relative;
padding-bottom: 56.25%;
height: 0; overflow: hidden;
max-width: 100%; height: auto;
}
.embed-container iframe, .embed-container object, .embed-container embed {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
</style>
<div class='embed-container'><iframe src='https://player.vimeo.com/video/208791851?autoplay=1&loop=1&background=1' frameborder='0' webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe></div>
但我的底部和顶部仍然有黑边。
我创建了一个 jsfiddle,您也可以在其中看到:https://jsfiddle.net/07fkfwz3/ . And the video that you can see here 没有任何边框。
试试这个
<style>
.embed-container {
position: relative;
padding-bottom: 56.25%;
height: 0; overflow: hidden;
max-width: 100%; height: auto;
}
.embed-container iframe, .embed-container object, .embed-container embed {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
</style>
<div class='embed-container'><iframe src='https://player.vimeo.com/video/208176323?autoplay=1&loop=1&background=1' frameborder='0' webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe></div>
编辑
所以在我看到 fiddle 之后,我设法解决了你的问题:
CSS
.embed-container {
position: relative;
padding-bottom: 56.25%;
height: 0;
overflow: hidden;
max-width: 100%;
height: auto;
}
.embed-container iframe,
.embed-container object,
.embed-container embed {
position: absolute;
top: 13%;
width: 100%;
height: 75%;
}
HTML
<div class='embed-container'>
<iframe src='https://player.vimeo.com/video/208791851?autoplay=1&loop=1&background=1' frameborder='0' webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
</div>
你可以试试这个:
https://jsfiddle.net/c4j73z16/4/
html
<div class='embed-container'>
<div class="vcontent">
<iframe src="https://player.vimeo.com/video/208176323?autoplay=1&loop=1&title=0&byline=1&portrait=1" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div>
</div>
css
<style>
.embed-container {
position: relative;
padding-bottom: calc(70vh - 6.7em);
height: 0;
overflow: hidden;
max-width: 100%;
}
.embed-container .vcontent {
position: absolute;
overflow: hidden;
height: calc(70vh - 6.2em);
width: 100%;
margin-top: -0.5em;
}
.embed-container iframe,
.embed-container object,
.embed-container embed {
position: absolute;
overflow: hidden;
top: 0;
left: 0;
width: 100%;
height: 70vh;
padding: 0;
margin: -3em 0;
}
</style>
我使用 vh
高度和进一步的 div.vcontent
来正确移动以更好地匹配您的需要。
HTML 是
<div class='container'>
<div class="vcontent">
<iframe src="https://player.vimeo.com/video/208791851?autoplay=1&loop=1&background=1" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div>
</div>
以及造型
.container {
position: relative;
padding-bottom: calc(70vh - 6.7em);
height: 0;
overflow: hidden;
max-width: 100%;
}
.container .vcontent {
position: absolute;
overflow: hidden;
height: calc(70vh - 6.2em);
width: 100%;
margin-top: -0.5em;
}
.container iframe,
.container object,
.container embed {
position: absolute;
overflow: hidden;
top: 0;
left: 0;
width: 100%;
height: 70vh;
padding: 0;
margin: -3em 0;
}
您为容器创建的魔法填充数需要与视频的宽高比相匹配。如果您检查 vimeo 上的视频,分辨率为 1296x540。要获得宽高比百分比,请除以 540 / 1296 * 100% = 41.66666667% padding。
这是一个 fiddle,因为视频在 SO 沙盒中似乎播放效果不佳。 https://jsfiddle.net/mcoker/p7q6x4d5/1/
.embed-container {
--video--width: 1296;
--video--height: 540;
position: relative;
padding-bottom: calc(var(--video--height) / var(--video--width) * 100%); /* 41.66666667% */
overflow: hidden;
max-width: 100%;
background: black;
}
.embed-container iframe,
.embed-container object,
.embed-container embed {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
<div class='embed-container'>
<iframe src='https://player.vimeo.com/video/208791851?autoplay=1&loop=1&background=1' frameborder='0' webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
</div>
这对我有用:
<style>
.embed-container {
position: relative;
padding-bottom: 56.25%;
height: 0;
overflow: hidden;
max-width: 100%;
}
.embed-container iframe,
.embed-container object,
.embed-container embed {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
</style>
<div class='embed-container'><iframe src='https://player.vimeo.com/video/157467640?background=1' frameborder='0' webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe></div>
来源:https://forum.webflow.com/t/setting-vimeo-video-to-full-width-of-div/25499/2
替换视频的ID号(本例为19022044)
HTML:
<div class="vimeo-full-width">
<iframe src="https://player.vimeo.com/video/19022044?title=0&byline=0&portrait=0" frameborder="0" allow="autoplay; fullscreen" allowfullscreen></iframe>
</div>
CSS:
.vimeo-full-width {
padding: 56.25% 0 0 0;
position: relative;
}
.vimeo-full-width iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
由于宽高比 16:9
,顶部内边距为 56.25%
我正在尝试在网页中以全宽显示一个 vimeo 视频。
这是现在的样子:
如您所见,黑色是全宽但不是视频。它应该是全角的,不显示控件,自动播放和循环播放。
我的代码现在看起来像这样:
<iframe src="https://player.vimeo.com/video/208176323?autoplay=1&loop=1&background=1" width="100%" height="500px" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
客户端有vimeo plus但没有vimeo pro。谁能帮我解决这个问题。
更新:
我已将我的代码更改为:
<style>
.embed-container {
position: relative;
padding-bottom: 56.25%;
height: 0; overflow: hidden;
max-width: 100%; height: auto;
}
.embed-container iframe, .embed-container object, .embed-container embed {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
</style>
<div class='embed-container'><iframe src='https://player.vimeo.com/video/208791851?autoplay=1&loop=1&background=1' frameborder='0' webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe></div>
但我的底部和顶部仍然有黑边。
我创建了一个 jsfiddle,您也可以在其中看到:https://jsfiddle.net/07fkfwz3/ . And the video that you can see here 没有任何边框。
试试这个
<style>
.embed-container {
position: relative;
padding-bottom: 56.25%;
height: 0; overflow: hidden;
max-width: 100%; height: auto;
}
.embed-container iframe, .embed-container object, .embed-container embed {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
</style>
<div class='embed-container'><iframe src='https://player.vimeo.com/video/208176323?autoplay=1&loop=1&background=1' frameborder='0' webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe></div>
编辑
所以在我看到 fiddle 之后,我设法解决了你的问题:
CSS
.embed-container {
position: relative;
padding-bottom: 56.25%;
height: 0;
overflow: hidden;
max-width: 100%;
height: auto;
}
.embed-container iframe,
.embed-container object,
.embed-container embed {
position: absolute;
top: 13%;
width: 100%;
height: 75%;
}
HTML
<div class='embed-container'>
<iframe src='https://player.vimeo.com/video/208791851?autoplay=1&loop=1&background=1' frameborder='0' webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
</div>
你可以试试这个: https://jsfiddle.net/c4j73z16/4/
html
<div class='embed-container'>
<div class="vcontent">
<iframe src="https://player.vimeo.com/video/208176323?autoplay=1&loop=1&title=0&byline=1&portrait=1" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div>
</div>
css
<style>
.embed-container {
position: relative;
padding-bottom: calc(70vh - 6.7em);
height: 0;
overflow: hidden;
max-width: 100%;
}
.embed-container .vcontent {
position: absolute;
overflow: hidden;
height: calc(70vh - 6.2em);
width: 100%;
margin-top: -0.5em;
}
.embed-container iframe,
.embed-container object,
.embed-container embed {
position: absolute;
overflow: hidden;
top: 0;
left: 0;
width: 100%;
height: 70vh;
padding: 0;
margin: -3em 0;
}
</style>
我使用 vh
高度和进一步的 div.vcontent
来正确移动以更好地匹配您的需要。
HTML 是
<div class='container'>
<div class="vcontent">
<iframe src="https://player.vimeo.com/video/208791851?autoplay=1&loop=1&background=1" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div>
</div>
以及造型
.container {
position: relative;
padding-bottom: calc(70vh - 6.7em);
height: 0;
overflow: hidden;
max-width: 100%;
}
.container .vcontent {
position: absolute;
overflow: hidden;
height: calc(70vh - 6.2em);
width: 100%;
margin-top: -0.5em;
}
.container iframe,
.container object,
.container embed {
position: absolute;
overflow: hidden;
top: 0;
left: 0;
width: 100%;
height: 70vh;
padding: 0;
margin: -3em 0;
}
您为容器创建的魔法填充数需要与视频的宽高比相匹配。如果您检查 vimeo 上的视频,分辨率为 1296x540。要获得宽高比百分比,请除以 540 / 1296 * 100% = 41.66666667% padding。
这是一个 fiddle,因为视频在 SO 沙盒中似乎播放效果不佳。 https://jsfiddle.net/mcoker/p7q6x4d5/1/
.embed-container {
--video--width: 1296;
--video--height: 540;
position: relative;
padding-bottom: calc(var(--video--height) / var(--video--width) * 100%); /* 41.66666667% */
overflow: hidden;
max-width: 100%;
background: black;
}
.embed-container iframe,
.embed-container object,
.embed-container embed {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
<div class='embed-container'>
<iframe src='https://player.vimeo.com/video/208791851?autoplay=1&loop=1&background=1' frameborder='0' webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
</div>
这对我有用:
<style>
.embed-container {
position: relative;
padding-bottom: 56.25%;
height: 0;
overflow: hidden;
max-width: 100%;
}
.embed-container iframe,
.embed-container object,
.embed-container embed {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
</style>
<div class='embed-container'><iframe src='https://player.vimeo.com/video/157467640?background=1' frameborder='0' webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe></div>
来源:https://forum.webflow.com/t/setting-vimeo-video-to-full-width-of-div/25499/2
替换视频的ID号(本例为19022044)
HTML:
<div class="vimeo-full-width">
<iframe src="https://player.vimeo.com/video/19022044?title=0&byline=0&portrait=0" frameborder="0" allow="autoplay; fullscreen" allowfullscreen></iframe>
</div>
CSS:
.vimeo-full-width {
padding: 56.25% 0 0 0;
position: relative;
}
.vimeo-full-width iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
由于宽高比 16:9
,顶部内边距为 56.25%