【发布时间】:2018-04-05 00:24:19
【问题描述】:
我正在创建一个 Ionic 应用程序,我想使用自定义字体“Rubik”。我已经导入了“更轻”和“更粗”的字体粗细,但它们似乎不起作用——无论我在哪里添加样式,它都只使用正常的字体粗细。代码如下:
@font-face {
font-family: 'Rubik';
src: url('#{$font-path}/Rubik-Light.otf') format('opentype');
font-weight: lighter;
font-style: normal;
}
@font-face {
font-family: 'Rubik';
src: url('#{$font-path}/Rubik-Regular.otf') format('opentype');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'Rubik';
src: url('#{$font-path}/Rubik-Bold.otf') format('opentype');
font-weight: bold;
font-style: normal;
}
@font-face {
font-family: 'Rubik';
src: url('#{$font-path}/Rubik-Black.otf') format('opentype');
font-weight: bolder;
font-style: normal;
}
我也试过了:
@import url('https://fonts.googleapis.com/css?family=Rubik');
这些被放置在 variables.scss 文件中。目前,如果我像往常一样将它分配给一个新的字体系列,我只能使用更轻/更粗的字体。对于使用 ionic (roboto、noto-sans)安装的默认字体,更轻更粗的字体效果很好。有什么想法吗?
【问题讨论】:
-
我认为
font-weight不再需要了,因为字体已经定义了权重。只需为每种字体使用一个唯一的名称就可以了
标签: html css angular fonts ionic2