【问题标题】:CSS font-face not working for ttfCSS font-face 不适用于 ttf
【发布时间】:2017-04-28 11:29:09
【问题描述】:

我正在像这样使用@font-face:

@font-face {
    font-family: DINPro;
    font-weight: bold;
    src: url(../res/fonts/DINPro-Bold.otf) format("opentype");
}
@font-face {
    font-family: DINPro;
    src: url(../res/fonts/DINPro-Regular.otf) format("opentype");
}
@font-face {
    font-family: DFLiHei;
    src: url(../res/fonts/DFLiHei-Regular.ttf) format('truetype');
}
h1{
    font-family: DFLiHei !important;
}

但不工作。 我的文件夹结构很可能:

/index.html
/css/style.css
/res/fonts/DINPro-Bold.otf
/res/fonts/DINPro-Regular.otf
/res/fonts/DFLiHei-Regular.ttf

因此,我认为错误的目录不是我的问题。 此外,不仅在特殊浏览器中失败,而且在 chrome 和移动设备中也失败。 有什么想法吗?

【问题讨论】:

标签: css font-face


【解决方案1】:

将ttf转换为woff格式

Try this

@font-face {
    font-family: DFLiHei;
    src: url(../res/fonts/DFLiHei-Regular.woff) format('woff');
}

它适用于所有浏览器

【讨论】:

    猜你喜欢
    • 2011-04-15
    • 2012-06-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-20
    • 2012-08-09
    • 1970-01-01
    • 2014-01-06
    相关资源
    最近更新 更多