Text with Gradient Background

Text with Gradient Background

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”]  
 
[gravityform id=”1″ title=”False”]  

Photo by Sam Headland on Unsplash

Why no ads?

Hi, my name is PK, and welcome to my website, almost inevitable design. I maintain and publish on this site for two reasons.

  1. To give back to the community. I learned so much from people's tutorials and StackOverflow that I wanted to contribute and help others.
  2. To provide a more structured learning experience. People struggle to find the course that guides them from start to finish, based off of real life experience, and my courses provide that.

The only "ads" I have here are for my own courses, and maybe an affiliate link, but that's it. They fund the website resources and provide more motivation for me to product better content.

Any bit of interest helps. Even sharing with your feidns, suggesting my courses to your developer or designer, or subscribing to my YT channel, or joining our Discord. Thanks and I'll see you around!

The Web Design Space

TWDS is my web design agency. If you're looking for premium quality, reliable, web design and development, come see what we're about!
Learn More
Choose "Paythen" at checkout for an interest free 10 week payment plan.
Leave a Reply

Your email address will not be published. Required fields are marked *

    New tutorials