JSFiddle - React, Tailwind, and code Playground
by Craig Haywood
HTML
<div class="video-background">
<iframe src="https://www.youtube.com/embed/UoqScLK8tBw?controls=0&showinfo=0&rel=0&autoplay=1&loop=1&mute=1&version=3&playlist=UoqScLK8tBw" frameborder="0" allowfullscreen></iframe>
</div>
<div class="mydiv">
</div>
CSS
.video-background {
position: relative;
overflow: hidden;
width: 100vw;
height: 100vh;
}
.video-background iframe {
position: absolute;
top: 50%;
left: 50%;
width: 100vw;
height: 100vh;
transform: translate(-50%, -50%);
}
@media (min-aspect-ratio: 16/9) {
.video-background iframe {
/* height = 100 * (9 / 16) = 56.25 */
height: 56.25vw;
}
}
@media (max-aspect-ratio: 16/9) {
.video-background iframe {
/* width = 100 / (9 / 16) = 177.777777 */
width: 177.78vh;
}
}
.mydiv{
background-color: rgba(0,0,0,.7);
position: absolute;
z-index: 10 ! important;
width: 100vw;
height: 100vh;
top: 0
}