如何更新已经存在的@ font-face贬值?

时间:2019-03-06 11:50:14

标签: css font-face cascade

我已经定义了字体声明了

@font-face {
  font-family: 'some font';
  src: url('somelink') format('woff');
  font-weight: 900;
  font-style: normal;
}

我没有能力编辑此代码,但是我需要再添加一个声明(font-display:可选),有没有办法做到这一点?

当前我正在做的是,我只是在样式表中覆盖此声明,而我可以通过以下方式进行控制:

@font-face {
  font-family: 'some font';
  src: url('somelink') format('woff');
  font-weight: 900;
  font-style: normal;
  font-display: optional;
}

但是我什至不确定它是否有效。您将如何测试?有更好的方法吗?预先感谢。

1 个答案:

答案 0 :(得分:0)

您不能覆盖@font-face定义。

常见做法是使用其他名称创建新的@font-face,然后在font-family中使用新名称:

@font-face {
  font-family: 'some font 2';
  src: url('somelink') format('woff');
  font-weight: 900;
  font-style: normal;
  font-display: optional;
}

.item {
  font-family: 'some font 2`
}