我正在尝试使用 HTML 和 CSS(没有 PHP 也没有 JQuery)创建一个嵌入式动态视频背景。背景必须适合视口(viewport)的整个宽度和高度。我能够创建动态视频,但现在我很难将其设为固定背景。当我将 position
更改为 fixed
时,视频不是全屏的。我浏览了无数教程,但无法找到我要找的东西。这是我到目前为止所拥有的:
CSS
.video-container {
position: relative;
padding-bottom: 56.25%;
padding-top: 30px; height: 0; overflow: hidden;
}
.video-container iframe,
.video-container object,
.video-container embed {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index:0;
}
HTML
<div class="video-container">
<iframe src="http://www.youtube.com/embed/dFVxGRekRSg" frameborder="0" width="560" height="315"></iframe>
</div>
最佳答案
这对您有用吗?
<style>
.video-container{
position:absolute;
top:0;
width:100%;
height:100%;
z-index: -55;
}
#test{
color:white;
width:220px;
margin:300px auto;
}
</style>
<div class="video-container">
<iframe style="border: none" src="http://www.youtube.com/embed/dFVxGRekRSg" height="100%" width="100%" scrolling="no" allowfullscreen webkitallowfullscreen mozallowfullscreen oallowfullscreen msallowfullscreen></iframe>
</div>
<div>
<h2 id="test">Other content</h2>
</div>
关于html - 使用 HTML 和 CSS 嵌入固定动态视频作为背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27575749/