Video background

In this pattern, the video is displayed in the background.
<div class="container">
<!-- The video container -->
<div class="container__wrapper">
<video class="container__video" src="...">
...
</video>
</div>
<!-- The content -->
<div class="container__content">
...
</div>
</div>
.container {
/* Used to position the video and content */
position: relative;
}
.container__wrapper {
/* Positioned at the top left corner */
left: 0px;
position: absolute;
top: 0px;
/* Take full size */
height: 100%;
width: 100%;
/* Hide the scrollbar */
overflow: hidden;
}
.container__video {
object-fit: cover;
/* Center the video */
left: 50%;
position: absolute;
top: 50%;
transform: translate(-50%, -50%);
/* Take full width */
width: 100%;
}
.container__content {
/* Positioned at the top left corner */
left: 0px;
position: absolute;
top: 0px;
/* Take full size */
height: 100%;
width: 100%;
/* Center the content */
align-items: center;
display: flex;
flex-direction: column;
justify-content: center;
}

See also

Full background

Overlay play button