Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS - dashed color font

I have to show the text on webpage which looks like:

enter image description here

The font has two alternate colors. Is it even possible? The solution should work for all the browsers.

like image 709
adnan kamili Avatar asked Aug 01 '26 22:08

adnan kamili


2 Answers

Yes, it's possible if you have proper font file that can be included in your page.

@font-face {
    font-family: myFirstFont;
    src: url(dashed_font.woff);
}
like image 172
Justinas Avatar answered Aug 04 '26 10:08

Justinas


This can be done natively in CSS without using a custom font in Google Chrome and other WebKit browsers using -webkit-background-clip.

h1 {
    font-family: sans-serif;
    font-size: 300%;
    background: repeating-linear-gradient(
        135deg,
        #3f3f3f,
        #3f3f3f 2px,
        #7f7f7f 2px,
        #7f7f7f 4px
    );
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
<h1>Your text here</h1>

Note that this will just display as text in front of a rectangular stripy background in other browsers such as Firefox or IE.

This article explains -webkit-background-clip and a few fallbacks for other browsers.

This article explains making striped backgrounds in plain CSS3.

like image 33
Candy Gumdrop Avatar answered Aug 04 '26 11:08

Candy Gumdrop



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!