Font-Face未加载

Chl*_*bta 1 html css html5 css3 font-face

我在我的网站上使用了一些服装字体,但我遇到了一个没有加载的问题,我无法弄清楚问题,这里是代码:

@font-face { 
    font-family: OuachitaWayWbw; 
    src: url('fonts/Ouachita Way Wbw.ttf') format("truetype") ; 
    font-family: 'ChromeYellowNF'; 
    src: url('fonts/Chrome Yellow NF.ttf');
}

#name { 
    font-size:26px; 
    font-family: 'OuachitaWayWbw'; 
    padding-top:30px; 
    color:#000000; 
    margin-bottom:20px; 
}
Run Code Online (Sandbox Code Playgroud)

ChromeYellowNF工作的.我也试图把每一个都放在不同的Font-face但没有奏效.

97l*_*ave 7

你必须为每种字体都有一个@ font-face声明:

@font-face { 
  font-family: OuachitaWayWbw; 
  src: url('fonts/Ouachita Way Wbw.ttf') format("truetype") ; 
}
@font-face { 
  font-family: ChromeYellowNF; 
  src: url('fonts/Chrome Yellow NF.ttf');
}
Run Code Online (Sandbox Code Playgroud)

单引号不是必需的.

如果您想为IE9使用自定义字体,您还需要提供".eot"字体文件.http://www.w3schools.com/cssref/css3_pr_font-face_rule.asp

编辑:好的,不同的浏览器有不同的实现字体的方式:

@font-face {
   font-family: OuachitaWayWbw; 
   src: url('fonts/Ouachita Way Wbw.ttf') format("truetype"),
        url('fonts/Ouachita Way Wbw.woff') format("woff");
   src: url('fonts/Ouachita Way Wbw.eot');
}
Run Code Online (Sandbox Code Playgroud)

您可能还需要将以下类型添加到.htaccess/IIS:

AddType application/vnd.ms-fontobject .eot
AddType font/ttf .ttf
AddType font/otf .otf
AddType application/x-font-woff .woff
Run Code Online (Sandbox Code Playgroud)

取自此处:Chrome中的MIME类型错误的font-face