Cover Video Intro with SVG

by Cristofer Sousa

HTML

<header class="svg-header">
  
      <svg>
      OPENSANCA MEETUP
         <mask id="mask">
            <rect width="100%" height="100%"/>
            <text>
              <tspan x="0" y="60%"> OPENSANCA</tspan>
              <tspan x="0" dy="0.8em"> MEETUP</tspan>
            </text>
          </mask>
          <rect width="100%" height="100%"/>
      </svg>

        <video loop  src="https://s3-us-west-2.amazonaws.com/coverr/mp4/Hello-World.mp4" autoplay loop muted></video>
    </header>

    <div class="container">
      <section>
        <h1>Welcome Opensanca</h1>
        <p>
          Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
        </p>
      </section>
    </div>

CSS

@import url(https://fonts.googleapis.com/css?family=Open+Sans);  
 
 body {
  font-family:'Open Sans', sans-serif;
  margin: 0;
}

.container {
  width: 90%;
  max-width: 800px;
  margin: 0 auto;
}

section {
  padding: 10em 0;
}

header {
  font-size: 16vw;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

svg {
  font-weight: 800;
  width: 100%;
  height: 100%;
  position:absolute;
}

svg mask rect{
  fill: rgba(140, 78, 78, 0.9);
}

svg > rect {
  fill: white;
  -webkit-mask: url(#mask);
  mask: url(#mask);
}

video {
  min-width: 100%;
  min-height: 100%;
  width: auto;
  height: auto;
}

JavaScript

var hasMask = document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#Mask", "1.0");