Skip to content

Instantly share code, notes, and snippets.

@rachelnabors
Last active December 12, 2015 03:39
Show Gist options
  • Save rachelnabors/4708657 to your computer and use it in GitHub Desktop.
Save rachelnabors/4708657 to your computer and use it in GitHub Desktop.
A CodePen by Rachel Nabors. Text Clipping Sass mixin - Based on Divya Manian's pure CSS background clipping solution. Now you can clip text to your heart's content without fear of disappearing text in non-webkit browsers!
<h1>Hello!</h1>
/* The background clip for text mixin */
/* Based on Divya's pure CSS solution: http://nimbupani.com/using-background-clip-for-text-with-css-fallback.html */
@mixin clip-text($img-url, $color: #000) {
color: $color;
-webkit-text-fill-color: transparent;
background: -webkit-linear-gradient(transparent, transparent),
url($img-url) repeat;
background: -o-linear-gradient(transparent, transparent);
-webkit-background-clip: text;
}
/* The mixin in action... */
h1 {
@include clip-text("http://stash.rachelnabors.com/codepen/text-clip-mixin/cloth.jpg", #fff);
font-family: OstrichSansBlack;
font-size: 5em;
margin: 2em 0;
text-align: center;
}
/* Other Styles */
body { background: #444; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment