Multi-colored text in CSS (#snippet)

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!

See the Pen
Multi Colored…


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


Print Share Comment Cite Upload Translate Updates
APA

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/

MLA
" » Multi-colored text in CSS (#snippet)." Stefan Judis | Sciencx - Thursday July 8, 2021, https://www.scien.cx/2021/07/08/multi-colored-text-in-css-snippet/
HARVARD
Stefan Judis | Sciencx Thursday July 8, 2021 » Multi-colored text in CSS (#snippet)., viewed ,<https://www.scien.cx/2021/07/08/multi-colored-text-in-css-snippet/>
VANCOUVER
Stefan Judis | Sciencx - » Multi-colored text in CSS (#snippet). [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/07/08/multi-colored-text-in-css-snippet/
CHICAGO
" » Multi-colored text in CSS (#snippet)." Stefan Judis | Sciencx - Accessed . https://www.scien.cx/2021/07/08/multi-colored-text-in-css-snippet/
IEEE
" » Multi-colored text in CSS (#snippet)." Stefan Judis | Sciencx [Online]. Available: https://www.scien.cx/2021/07/08/multi-colored-text-in-css-snippet/. [Accessed: ]
rf:citation
» Multi-colored text in CSS (#snippet) | Stefan Judis | Sciencx | 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.

You must be logged in to translate posts. Please log in or register.