【发布时间】:2017-10-20 01:05:09
【问题描述】:
我正在使用通过@font-face 加载的三种字体,它们看起来都应该在 Chrome 上使用,但在 Firefox 和 IE 上它们看起来不同。就像添加了额外的粗体一样,它们更加块状。
@font-face {
font-family: 'OpenSans-Regular';
src: url('../fonts/OpenSans-Regular-webfont.woff') format('woff');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'Montserrat-Regular';
src: url('../fonts/montserrat-regular-webfont.woff2') format('woff2'),
url('../fonts/montserrat-regular-webfont.woff') format('woff');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'Roboto-Regular';
src: url('../fonts/roboto-regular-webfont.woff2') format('woff2'),
url('../fonts/roboto-regular-webfont.woff') format('woff');
font-weight: normal;
font-style: normal;
}
我如何将这些字体应用于元素:
...
font-family: "OpenSans-Regular", sans-serif;
...
如果我使用开发工具在 Firefox 中编辑该元素并设置 font-family: Open Sans,那么它会正常工作。
这个问题让我很头疼,因为我不明白为什么会这样。
【问题讨论】:
-
在 CSS 注释中,不要将字体样式、粗细等放在您的字体系列名称中。它们是
OpenSans、Montserrat和Roboto,明确 绑定到字体样式“常规”和字体粗细“正常”,因此您可以控制这些字体是否通过这三个值。您使用@font-face来声明一个family,然后CSS 根据其他属性将该系列解析为单独的资源。这就是为什么您可以为同一个姓氏制定 20 条不同的规则,但权重/风格/等不同。组合。
标签: css google-chrome firefox fonts