CSS font-face不适用于ttf

时间:2017-04-28 03:08:01

标签: css font-face

我正在使用@ 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和移动设备中失败。 有什么想法吗?

1 个答案:

答案 0 :(得分:0)

ttf转换为woff格式

Try this

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

它适用于所有浏览器

相关问题