如何更新已存在的@ font-face声明?

问题描述 投票:1回答:1

我有一个案例,我已经定义了font-face声明

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

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

目前我在做的是我只是在样式表中覆盖这个声明,我可以控制这样的声明:

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

但我甚至不确定它是否有效。你会怎么测试?有没有更好的方法呢?提前致谢。

css font-face cascade
1个回答
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`
}
© www.soinside.com 2019 - 2024. All rights reserved.