About this snippet

Create a cinematic impact with a video text mask. We use CSS blend modes to play a background video directly inside your typography, which looks amazing.

Size
1.4 KB
Uses
HTML, CSS
Loads
codeshack.io
Views
256
<div class="video-mask-container">
  <video class="bg-video" autoplay muted loop playsinline>
    <source src="https://codeshack.io/web/example.mp4" type="video/mp4">
  </video>
  
  <div class="text-mask-layer">
    <h1>CREATIVE</h1>
    <h1>VISION</h1>
  </div>
</div>
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  font-family: system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  margin: 0;
  background: #000000;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.video-mask-container {
  position: relative;
  width: 100%;
  height: 100vh;
  overflow: hidden;
}

.bg-video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
}

.text-mask-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* Pure black background with white text, utilizing multiply blend mode, completely reveals the video purely inside the text strokes */
  background: #000000;
  color: #ffffff;
  mix-blend-mode: multiply;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.text-mask-layer h1 {
  font-size: clamp(4rem, 12vw, 15rem);
  font-weight: 900;
  line-height: 0.9;
  margin: 0;
  letter-spacing: -2px;
  text-transform: uppercase;
}
Esc
↑↓ moveEnter select

Start from a template

Open an .html file, or HTML, CSS, JS, Markdown, Less or TypeScript files. You can also drop them here. Styles and scripts go into their panes.

Share

Source

Keyboard shortcuts

Save