cod*_*dek 7 html javascript css jquery
我遇到的问题是视频的侧面或顶部/底部总是有黑条,具体取决于屏幕尺寸.

任何想法如何让它全屏显示总是没有显示恼人的黑条?并且不使用插件.
这是我的标记:
<div id="full-bg">
<div class="box iframe-box" width="1280" height="800">
<iframe src="http://player.vimeo.com/video/67794477?title=0&byline=0&portrait=0&color=0fb0d4" width="1280" height="720" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
#full-bg{
width: 100%;
height: 100%;
img{
display: none;
}
.iframe-box{
width: 100%;
height: 100%;
position: absolute;
background: url(../img/fittobox.png);
left: 0 !important;
top: 0 !important;
iframe{
width: 100%;
height: 100%;
}
}
}
Run Code Online (Sandbox Code Playgroud)
尝试添加到您的CSS
.iframe-box {
max-width: 1280px; /* video width */
max-height: 720px; /* video height */
}
Run Code Online (Sandbox Code Playgroud)
这意味着,width: 100%; height: 100%将让元件将膨胀,也同样可以,直到它碰到的最大高度或宽度720px或1280px分别.
如果您正在查看的屏幕具有更高的分辨率,则节点将停止扩展,您将不会有黑色边框.
此外,afaik以下是无效的CSS,你使用的是库还是什么?
#full-bg {
.iframe-box {
foo: bar;
}
}
Run Code Online (Sandbox Code Playgroud)
接受回答后编辑:我只是想到了一种完全不同的方法来实现这一点,但它需要你改变很多CSS
.fittobox { /* give fit to box an aspect ratio */
display: inline-block; /* let it be styled thusly */
padding: 0; /* get rid of pre-styling */
margin: 0;
width: 100%; /* take up full width available */
padding-top: 56.25%; /* give aspect ratio of 16:9; "720 / 1280 = 0.5625" */
height: 0px; /* don't want it to expand beyond padding */
position: relative; /* allow for absolute positioning of child elements */
}
.fittobox > iframe {
position: absolute; /* expand to fill */
top: 0px;
left: 0px;
right: 0px;
bottom: 0px;
}
Run Code Online (Sandbox Code Playgroud)