我需要用全幅youtube视频加载该部分的背景内容,我在下面的代码中对视频背景没有问题,但是另一部分却重叠了,无法正确显示,该怎么做另一个部分显示出来?
<style>
.video-foreground,
.video-background iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
}
@media (min-aspect-ratio: 16/9) {
.video-foreground { height: 300%; top: -100%; }
}
@media (max-aspect-ratio: 16/9) {
.video-foreground { width: 300%; left: -100%; }
}
.sub-content {
position: absolute;
top: 0px;
padding: 30px;
color: #FFF;
text-shadow: #000 2px 2px;
}
</style>
</head>
<body>
<section id="content1" style="background-color:#ccc;">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. </p>
</section>
<section>
<div class="video-background">
<div class="video-foreground">
<iframe src="https://www.youtube.com/embed/2L515SmPbRw?controls=0&showinfo=0&rel=0&autoplay=1&loop=1&mute=1" frameborder="0" allowfullscreen></iframe>
</div>
</div>
<div class="sub-content">
<h1>Hello World!</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div>
</section>
<section id="content2" style="background-color:#ddd;">
<p>Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet.</p>
</section>
</body>
答案 0 :(得分:0)
.video-wrapper {
position: relative;
padding: 25px 0 56.25% 0; /*16:9*/
height: 0;
margin-bottom: 50px;
iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.sub-content {
position: absolute;
top: 5%;
color: #ffffff;
}
}
.info {
position : relative;
width: 100%;
clear: both;
background: #f8c1cb;
}
https://codepen.io/pgurav/pen/GRgRpZP
不确定您的问题。但希望这是您要寻找的东西