我正在尝试在网页中显示全宽的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/。您可以看到here的视频没有任何边框。
答案 0 :(得分:36)
您为容器创建的魔术填充号码需要与视频的宽高比相匹配。如果您在vimeo上检查视频,则res为1296x540。要获得宽高比百分比,请将540/1296 = 41.66666667%填充除以。这是一个小提琴,因为视频似乎在SO沙箱中不能很好地播放。 https://jsfiddle.net/07fkfwz3/6/
.embed-container {
position: relative;
padding-bottom: 56.25%;
overflow: hidden;
}
.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>
答案 1 :(得分:5)
试试这个
<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>
所以在我看到小提琴之后我设法解决了你的问题:
.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%;
}
<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>
答案 2 :(得分: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%
答案 3 :(得分:0)
你可以试试这个: https://jsfiddle.net/c4j73z16/4/
<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>
<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
,以便更好地匹配您需要的内容。
答案 4 :(得分:0)
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;
}
答案 5 :(得分:0)
这对我有用:
<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