Last active
February 28, 2023 20:56
-
-
Save 2thecrow/4ad8be46da6623c71632627cd2554de9 to your computer and use it in GitHub Desktop.
How to add a gradient overlay to text with CSS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://fossheim.io/writing/posts/css-text-gradient/ | |
.gradient-text { | |
/* Fallback: Set a background color. */ | |
background-color: red; | |
/* Create the gradient. */ | |
background-image: linear-gradient(45deg, #f3ec78, #af4261); | |
/* Set the background size and repeat properties. */ | |
background-size: 100%; | |
background-repeat: repeat; | |
/* Use the text as a mask for the background. */ | |
/* This will show the gradient as a text color rather than element bg. */ | |
-webkit-background-clip: text; | |
-webkit-text-fill-color: transparent; | |
-moz-background-clip: text; | |
-moz-text-fill-color: transparent; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment