This content originally appeared on Stefan Judis Web Development and was authored by Stefan Judis
That's one for my bookmarks. ? I just came across this beautiful Pen by Shireen Taj. Occasionally, I'm googling how to do this with multi-color text effect with CSS and this example is just beautiful!
The trick is that you can define a gradient on the elements background, set the text color to transparent
and define background-clip: text
.
h1 {
/* more styling rules */
/* define a fancy background */
background: linear-gradient(219deg,
var(--color-1) 19%,
transparent 19%,transparent 20%,
var(--color-2) 20%, var(--color-2) 39%,
transparent 39%,transparent 40%,
var(--color-3) 40%,var(--color-3) 59% ,
transparent 59%,transparent 60%,
var(--color-4) 60%, var(--color-4) 79%,
transparent 79%, transparent 80%,
var(--color-5) 80%);
/* clip the background to the text */
background-clip: text;
-webkit-background-clip: text;
/* make the text color transparent (and invisible) */
color: transparent;
}
If you want to have a detailed look, check Shireen's CodePen. ☝️
Reply to Stefan
This content originally appeared on Stefan Judis Web Development and was authored by Stefan Judis
Stefan Judis | Sciencx (2021-07-08T19:30:00+00:00) Multi-colored text in CSS (#snippet). Retrieved from https://www.scien.cx/2021/07/08/multi-colored-text-in-css-snippet/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.