Here’s something that looks fun.
Gradient Text!
Even Animation!
Here’s the fiddle:
Of course, you’d want it in your own colors, right?
So just head on over to
Ultimate CSS Gradient Editor
for the gradient css codes and
Gradient Animator
for the animation.
Now that you’re all ready with your links and css codes and stuff, we can dive in.
Basically, what we’re going to do is take those gradients and use them as backgrounds to punched-out text.
So we take two elements: the background, and the punched out text.
Here’s an example of a gradient:
h1.grad-back { background: rgb(181,189,200); background: -moz-linear-gradient(left, rgba(181,189,200,1) 0%, rgba(130,140,149,1) 36%, rgba(40,52,59,1) 100%); background: -webkit-linear-gradient(left, rgba(181,189,200,1) 0%,rgba(130,140,149,1) 36%,rgba(40,52,59,1) 100%); background: linear-gradient(to right, rgba(181,189,200,1) 0%,rgba(130,140,149,1) 36%,rgba(40,52,59,1) 100%); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#b5bdc8', endColorstr='#28343b',GradientType=1 ); }
and here’s some punched out text:
.clipped { -webkit-background-clip: text; -webkit-text-fill-color: transparent;}
Add them together, and we get:
h1.grad-back { background: rgb(181,189,200); background: -moz-linear-gradient(left, rgba(181,189,200,1) 0%, rgba(130,140,149,1) 36%, rgba(40,52,59,1) 100%); background: -webkit-linear-gradient(left, rgba(181,189,200,1) 0%,rgba(130,140,149,1) 36%,rgba(40,52,59,1) 100%); background: linear-gradient(to right, rgba(181,189,200,1) 0%,rgba(130,140,149,1) 36%,rgba(40,52,59,1) 100%); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#b5bdc8', endColorstr='#28343b',GradientType=1 ); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
So that’s the first one. The one with just the gradient background.
Here’s what the animation looks like:
h1.moving { background: linear-gradient(270deg, #5b20ad, #2da9ef, #06b050, #e6da25); background-size: 800% 800%; -webkit-animation: blockbusteranimation 8s ease infinite; -moz-animation: blockbusteranimation 8s ease infinite; -o-animation: blockbusteranimation 8s ease infinite; animation: blockbusteranimation 8s ease infinite; -webkit-background-clip: text; -webkit-text-fill-color: transparent; } @-webkit-keyframes blockbusteranimation { 0%{background-position:0% 50%} 50%{background-position:100% 50%} 100%{background-position:0% 50%} } @-moz-keyframes blockbusteranimation { 0%{background-position:0% 50%} 50%{background-position:100% 50%} 100%{background-position:0% 50%} } @-o-keyframes blockbusteranimation { 0%{background-position:0% 50%} 50%{background-position:100% 50%} 100%{background-position:0% 50%} } @keyframes blockbusteranimation { 0%{background-position:0% 50%} 50%{background-position:100% 50%} 100%{background-position:0% 50%} }
[sc name=”customcss”]
So it’s pretty cool!
However… One problem:
As is with everything good on the internet, this does not work on IE.
Notice the “-webkit” part? Yeah, it doesn’t work on IE. So, you should probably add an IE specific stylesheet that just gives the text a single color.
So there you have it! A pretty awesome way to get gradients behind your text without using images. (for the modern browser people)
PS. The Divi theme version will be up real soon, and the link is here.
[sc name=”learn css”]
[sc name=”responsive-ad”]
[sc name=”podcast”]
Photo by Sam Headland on Unsplash