css - Chrome 中 MIME 类型错误的字体

标签 css google-chrome font-face

这是我使用的@font-face声明:

@font-face {
    font-family: SolaimanLipi;
    src: url("font/SolaimanLipi_20-04-07.ttf");
}

这在 Firefox 中运行良好,但在 Chrome 中运行不佳。 “检查元素”后,我收到以下消息:

Resource interpreted as font but transferred with MIME type application/octet-stream.

如有任何建议,我们将不胜感激。

最佳答案

和往常一样,不同的浏览器有不同的需求。这是一个跨浏览器的@fontface 声明,取自 Paul Irish blog -

@font-face {
  font-family: 'Graublau Web';
  src: url('GraublauWeb.eot');
  src: local('☺'),
         url('GraublauWeb.woff') format('woff'), url('GraublauWeb.ttf') format('truetype');
}

.eot 用于 IE,其余浏览器使用 .woff 或 .ttf 如果需要从源字体生成不同类型,可以使用 Font Squirrel 的 font-face generator

您还需要一个 .htaccess 到添加以下类型的字体的位置:

AddType application/vnd.ms-fontobject .eot
AddType font/ttf .ttf
AddType font/otf .otf
AddType application/x-font-woff .woff

关于css - Chrome 中 MIME 类型错误的字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4051826/

相关文章:

javascript - 为不同的浏览器添加类

javascript - 如何让图像在一行中一直贯穿整个屏幕

css - 更改 Sublime Text 3 中的默认 HTML 标签

javascript - 如何检测我是否在 google chrome 扩展应用程序中处于隐身模式?

javascript - 动画在 Chrome 中很流畅,但在 Firefox 中则不然

html - 特定字体以某种方式禁止 Webkit 浏览器中的仿斜体

javascript - 选中复选框时更改父背景

javascript - 控制台未出现在 Chrome 开发者工具的底部

css - 用 compass 编译字体

html - 两个@font-face 表现得不像对方