简体   繁体   English

CSS-重命名字体

[英]CSS - renaming fonts

A fellow programmer has built a page with webfonts, but didn't provide any fallbacks in the font-family rules for where they added this to the appropriate html elements. 一位程序员用网页字体构建了一个页面,但是没有在字体系列规则中提供任何回退,因为他们将其添加到适当的html元素中。

for example: 例如:

#someDiv { font-family: "my font"; }

In some special cases, we're not loading the webfont, and it looks pretty ugly. 在某些特殊情况下,我们没有加载webfont,它看起来很丑陋。 The font should fall back on Arial. 字体应回落到Arial上。 Instead of going over the CSS line-by-line and fix this, is there a way to add a font-face rule or something similar so that "my font" will show Arial? 除了逐行浏览CSS并解决此问题,还有没有办法添加字体规则或类似的规则,以便“我的字体”显示Arial?

Found the answer: 找到了答案:

@font-face {
    font-family: "my font";
    src: local("Arial");
}

将您的后备添加到当前的字体系列链中。

#someDiv { font-family: "my font", Arial, sans-serif; }

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

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