【问题标题】:CSS font face is not working on Mozilla Firefox, Microsoft Edge and OperaCSS 字体在 Mozilla Firefox、Microsoft Edge 和 Opera 上不起作用
【发布时间】:2018-12-24 03:31:32
【问题描述】:

我正在为网站使用“DinRoundWeb”和“DINRoundComp”字体系列。 CSS 样式表中的声明如下所示:

 @font-face {
 font-family: Din;
 src: url("fonts/DINRoundWeb.eot"), url("fonts/DINRoundWeb.woff")              format("woff"), url("fonts/DINRoundComp.ttf") format("truetype");
 font-weight: 400;
 }
 @font-face {
 font-family: Din;
 src: url("fonts/DINRoundWeb-Medium.eot"), url("fonts/DINRoundWeb-  Medium.woff") format("woff"), url("fonts/DINRoundComp-Medium.ttf")    format("truetype");
 font-weight: 600;

}

字体文件位于字体文件夹中。车身样式如下:

   body{
   font-family: Din ,sans;
   color: #444;
   line-height: 1.5rem;
   font-size: 1rem;
   background-color: #f3f3f3;
   }

该样式没有应用在页面中,而且不仅出现在Web Developer Tools-> Fonts-> All Fonts下。

如果有任何指示,我将不胜感激! 我的风格

【问题讨论】:

  • 可能是因为你有两个@font-face 规则具有相同的font-family 属性?

标签: html css fonts font-face


【解决方案1】:

从您的 css 文件的角度尝试一个相对路径。每个权重都需要一个额外的font-family,如下所示:

@font-face {
  font-family: 'DNRM';
  src: url('../fonts/DINRoundWeb-Medium.eot');
  src: url('../fonts/DINRoundWeb-Medium.eot?#iefix') format('embedded-opentype'), url('../fonts/DINRoundWeb-Medium.woff') format('woff');
}

@font-face {
  font-family: 'DNRR';
  src: url('../fonts/DINRoundWeb.eot');
  src: url('../fonts/DINRoundWeb.eot?#iefix') format('embedded-opentype'), url('../fonts/DINRoundWeb.woff') format('woff');
}

【讨论】:

  • 谢谢!它仅使用您的公式有效,我添加了“!important”关键字来覆盖 Bootstrap。
  • 另外请注意,没有官方浏览器可以理解eot,自 2016 年 1 月微软大举关闭 IE8 及以下版本,IE9 和 IE10 紧随其后,Vista 被永久关闭稍后。
  • 感谢@Mike'Pomax'Kamermans 指出这一点。这里有一个关于 SO 的链接:stackoverflow.com/questions/36105194/…
猜你喜欢
  • 2019-02-14
  • 1970-01-01
  • 2014-05-19
  • 2016-03-18
  • 2012-07-09
  • 2017-10-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多