如果我在 css 中定义自定义外部字体,是否需要为每个使用它的类声明 src?
如果我使用外部加载的字体(例如“MyFont”)并且它将在多个类中使用,我是否需要这样做:
.one { font-family: MyFont; src: url( "fonts/MyFont.ttf" ); }
.two { font-family: MyFont; src: url( "fonts/MyFont.ttf" ); }
或者我可以这样做吗?
.one { font-family: MyFont; src: url( "fonts/MyFont.ttf" ); }
.two { font-family: MyFont; }
If I am using an externally loaded font (e.g. "MyFont") and it's going to be used in multiple classes, do I need to do this:
.one { font-family: MyFont; src: url( "fonts/MyFont.ttf" ); }
.two { font-family: MyFont; src: url( "fonts/MyFont.ttf" ); }
or can I do this?
.one { font-family: MyFont; src: url( "fonts/MyFont.ttf" ); }
.two { font-family: MyFont; }
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不,请查看这篇文章:新的 Bulletproof @Font-Face 语法
在 CSS 文件的开头添加类似的内容:
使用此示例代码运行,CSS 的其余部分应如下所示:
No, check out this article: The New Bulletproof @Font-Face Syntax
Add something like this at the beginning of your CSS file:
Running with this sample code, the rest of your CSS should look something like:
您应该使用
@font-face
指令。You should use
@font-face
directive.