【发布时间】:2022-07-02 23:06:46
【问题描述】:
我正在尝试使用以下 CSS 来添加具有六种不同字体粗细的字体系列。
@font-face { font-family: myFont; font-weight: Thin; src: url('../fonts/myFont-Thin.ttf'); }
@font-face { font-family: myFont; font-weight: Light; src: url('../fonts/myFont-Light.ttf'); }
@font-face { font-family: myFont; font-weight: Medium; src: url('../fonts/myFont-Medium.ttf'); }
@font-face { font-family: myFont; font-weight: Regular; src: url('../fonts/myFont-Regular.ttf'); }
@font-face { font-family: myFont; font-weight: Bold; src: url('../fonts/myFont-Bold.ttf'); }
@font-face { font-family: myFont; font-weight: Black; src: url('../fonts/myFont-Black.ttf'); }
.myClass{
font-family: myFont, sans-serif;
font-weight: Medium;
}
当我尝试使用 myClass 类时,它使用字体粗细为 400 的 myFont-Bold.ttf,而不是使用字体粗细为 400 的 myFont-Medium.ttf。开发人员内部工具,我可以看到它只加载了我字体的两种字体粗细:粗体和黑色。当我删除黑色字体粗细的行时,它会以常规和粗体加载。为什么它只加载两个字体粗细而不是全部?
【问题讨论】: