【问题标题】:I cannot use @font-face [duplicate]我不能使用@font-face [重复]
【发布时间】:2020-01-25 16:49:30
【问题描述】:

我正在尝试实现一种自然语言形式。当我尝试在我的 CSHTML 页面中使用以下 CSS 时,我收到错误“名称 'font' 在当前上下文中不存在”

@font-face {
  font-family: 'nlicons';
  src:url('../fonts/nlicons/nlicons.eot');
  src:url('../fonts/nlicons/nlicons.eot?#iefix') format('embedded-opentype'),
    url('../fonts/nlicons/nlicons.woff') format('woff'),
    url('../fonts/nlicons/nlicons.ttf') format('truetype'),
    url('../fonts/nlicons/nlicons.svg#nlicons') format('svg');
  font-weight: normal;
  font-style: normal;
}

【问题讨论】:

  • 检查,您在“src”中提供的路径必须正确,并且字体必须在那里。然后使用 [ font-family: 'nlicons';] 到要显示此字体的 html 元素。

标签: css fonts font-face


【解决方案1】:

您必须转义 @ 符号。 @ 符号保留用于 razor 语法。

转义@ 写两次@@

@@font-face {
  font-family: 'nlicons';
  src:url('../fonts/nlicons/nlicons.eot');
  src:url('../fonts/nlicons/nlicons.eot?#iefix') format('embedded-opentype'),
    url('../fonts/nlicons/nlicons.woff') format('woff'),
    url('../fonts/nlicons/nlicons.ttf') format('truetype'),
    url('../fonts/nlicons/nlicons.svg#nlicons') format('svg');
  font-weight: normal;
  font-style: normal;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-08-29
    • 2013-12-03
    • 2012-08-31
    • 2011-10-20
    • 1970-01-01
    • 2019-08-12
    • 1970-01-01
    相关资源
    最近更新 更多