JSFiddle - React, Tailwind, and code Playground
by Oliver
HTML
<div class="bg-video">
<iframe class="bg-video__iframe" src="https://www.youtube.com/embed/biWk-QLWY7U?controls=0&showinfo=0&rel=0&autoplay=1&loop=1&mute=1" frameborder="0" allowfullscreen></iframe>
</div>
SCSS
* {
padding: 0;
margin: 0;
}
:root {
--video-width: 100vw;
--video-height: 100vh;
@media (min-aspect-ratio: 16/9) {
--video-height: 56.25vw;
}
@media (max-aspect-ratio: 16/9) {
--video-width: 177.78vh;
}
}
.bg-video {
position: relative;
overflow: hidden;
width: 100vw;
height: 100vh;
}
.bg-video__iframe {
position: absolute;
top: 50%;
left: 50%;
width: var(--video-width);
height: var(--video-height);
transform: translate(-50%, -50%);
}