Skip to content

Instantly share code, notes, and snippets.

@lesjames
Created January 18, 2012 01:59
Show Gist options
  • Save lesjames/1630326 to your computer and use it in GitHub Desktop.
Save lesjames/1630326 to your computer and use it in GitHub Desktop.
CSS Gradient Text
/*
* CSS Gradient Text
* currently webkit only
* CMS must duplicate the text into the title attribute so the CSS can pull it into the pseudo-element
*/
body { background: #333; font-family: Helvetica, sans-serif; font-size: 2em; padding: 3em 0; color: white; text-shadow: 0 -1px 1px rgba(0,0,0,.3); }
h1 { position: relative; width: 10em; margin: 0 auto; font-weight: normal; }
/* Duplicate the content and layer it over the original with a gradient mask */
h1::before {
content: attr(title); position: absolute; color: hotpink;
mask-image: linear-gradient(100deg, rgba(0,0,0,0), black);
}
<h1 title="When you're cool, the sun shines on you 24 hours a day.">When you're cool, the sun shines on you 24 hours a day.</h1>
{"view":"split","prefixfree":"1","page":"css"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment