Video as Text Background

In this tutorial, you will learn how to set a video as text background with CSS. Watch the video below for a detailed tutorial.


HTML

<body>
    <div class="container">
        <video autoplay loop muted>
            <source src="ocean.mp4" type="video/mp4">
        </video>
        <div class="banner">
            <h1>LOREM</h1>
        </div>
    </div>
</body>

CSS

body  {
    font-family: 'Oswald', sans-serif;
    background: url('sand.jpg') no-repeat center top / cover;
    margin: 0;
}

.container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100vh;
}

.container video {
    width: 100%;
    object-fit: cover;
    height: 20em;
}

.banner {
    position: absolute;
    width: 100%;
    top: 27%;
    font-size: 8em;
    text-align: center;
    background: white;
    color: black;
    mix-blend-mode: screen;
}

.banner h1 {
    margin: 0;
}

Sources

Ocean Video: https://www.pexels.com/video/bird-s-eye-view-of-ocean-waves-1918465/
White Sand image: https://www.pexels.com/photo/close-up-shot-of-white-sand-12872929/
Font: https://fonts.googleapis.com/css2?family=Oswald:wght@700&display=swap