html - CSS3 中的@font-face 不工作

标签 html css font-face

我正在尝试为我的网站做@font-face,但不幸的是它不起作用。 我试过:

@font-face {
    font-family: BN Shirly; /*Adding a custom font*/
    src: url('Fonts/BN Shirly.ttf');  /*Source of font*/
}

然后在 span 中我想将文本用于:

#categories span {
    color: white;
    font-family: 'BN Shirly';
    font-size: 30px; 
}

我该如何解决这个问题,以便我的自定义字体能够正常工作?

最佳答案

@font-face {
   font-family: BN-Shirly; /*Adding a custom font*/
   src: url('Fonts/BN-Shirly.ttf');  /*Source of font*/
}


#categories span {
    color: white;
    font-family: BN-Shirly;
    font-size: 30px; 
}

我刚看到字体族有空格,把空格去掉试试。并删除声明类中的引号。

更新

@font-face {
    font-family: 'BN-Shirly';
    src:    url('Fonts/BN-Shirly.ttf') format('truetype');
}

关于html - CSS3 中的@font-face 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13334622/

相关文章:

css - Visual Studio 不呈现@font-face,可能是相对路径问题?

html - octopress 生成中 css 文件的错误路径

javascript - 无法在 javascript 中访问全局变量?

javascript - 如何使用 ng-hide 根据 angularjs 中的特定条件仅显示选定的 div 元素

javascript - 在 HTML 中映射色彩空间

javascript - Jquery 中 droppable 中 draggable 被 droppable 如何设置结果?

css - Opera 不支持字体粗细(我的 Opera 版本是 12.02)

html - Bootstrap 只显示导航栏

javascript - Chrome 中的翻转动画显示非事件侧的一半元素

css - Google Web 字体在 Konqueror 上看起来不正确 - 粗体∧斜体