Skip to content

Instantly share code, notes, and snippets.

@iamnewton
Created July 21, 2015 01:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iamnewton/20b873351e307a10bdd3 to your computer and use it in GitHub Desktop.
Save iamnewton/20b873351e307a10bdd3 to your computer and use it in GitHub Desktop.
Cross-Browser Text Masks with Blend Modes

For effective clipping effects, a font that has bold lettering and thick strokes tends to work best.

Source

.dark {
background-image: url(image.jpg);
background-size: cover;
text-align: center;
h1 {
margin: 0;
background-color: rgb(0,0,0);
color: rgb(255,255,255);
font-family: Montserrat, sans-serif;
font-size: 20vw;
line-height: 1.9;
text-transform: uppercase;
mix-blend-mode: darken;
}
}
.reversal {
position: relative;
background: rgb(0,0,0);
h1 {
mix-blend-mode: none;
}
img {
position: absolute;
top: 0;
left: 0;
width: 100%;
mix-blend-mode: darken;
}
}
<!-- Text takes precedence over image -->
<div class="dark">
<h1>Text</h1>
</div
<!-- Image takes precedence over text -->
<div class="dark reversal">
<h1>Text</h1>
<img src="image.jpg" alt="" />
</div>
.dark {
background-image: url(image.jpg);
background-size: cover;
text-align: center;
}
.dark h1 {
margin: 0;
background-color: rgb(0,0,0);
color: rgb(255,255,255);
font-family: Montserrat, sans-serif;
font-size: 20vw;
line-height: 1.9;
text-transform: uppercase;
}
.reversal {
position: relative;
background: rgb(0,0,0);
}
.reversal h1 {
mix-blend-mode: none;
}
.reversal img {
position: absolute;
top: 0;
left: 0;
width: 100%;
mix-blend-mode: darken;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment