简体   繁体   English

CSS - 虚线颜色字体

[英]CSS - dashed color font

I have to show the text on webpage which looks like: 我必须在网页上显示如下文字:

在此输入图像描述

The font has two alternate colors. 字体有两种替代颜色。 Is it even possible? 它甚至可能吗? The solution should work for all the browsers. 该解决方案应适用于所有浏览器。

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);
}

This can be done natively in CSS without using a custom font in Google Chrome and other WebKit browsers using -webkit-background-clip . 这可以在CSS中本地完成,而无需在Google Chrome和其他使用-webkit-background-clip WebKit浏览器中使用自定义字体。

 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. 请注意,这只会在其他浏览器(如Firefox或IE)中的矩形条纹背景前显示为文本。

This article explains -webkit-background-clip and a few fallbacks for other browsers. 本文介绍了-webkit-background-clip以及其他浏览器的一些后备内容。

This article explains making striped backgrounds in plain CSS3. 本文介绍如何在纯CSS3中制作条纹背景。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM