如何链接到HTML文档中的.woff字体文件

Hir*_*ima 4 html5 css3 font-face font-family

我在计算机上安装了想要应用于HTML5 / CSS3的字体时遇到问题。

我的问题与可能重复的问题有何不同:它明确询问要在.html文件中放入什么,重复问题中未解决的问题。

解决问题后更新:

1)该<link href=....>行不得包含在.html文件中

2).woff字体文件必须与.css文件位于同一目录中。

这是我最小的工作CSS:

@font-face{
    font-family: Reef;
    src: local('../Fonts/Reef/reef-webfont.woff'), url('../Fonts/Reef/reef-webfont.woff') format('woff');
}

body, h1, h2{   
    text-align:center;
    font-family: 'Reef', monospace; 
}
Run Code Online (Sandbox Code Playgroud)

这是我最小的工作HTML文件:

<html>

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/
    libs/jquery/1.4.3/jquery.min.js"></script>
<script type="text/javascript"></script>    

    <head>
        <link rel="stylesheet" type="text/css"   href="bootstrap.css" />
        <link rel="stylesheet" href="stylesGrilcheeserie.css" type="text/css"/>     
        <link href='../Fonts/Reef/reef-webfont.woff' rel='stylesheet' type='text/css'>
        <title> Grilcheeserie </title>          
    </head>

    <body>

        <h1>La Grilcheeserie</h1>       

    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

无论我做什么,页面都会显示其备用字体,等宽字体而不是Reef。

我的问题是:如何正确引用html中的字体来源?据我从搜索答案中得知,我的CSS应该是正确的。

我在Windows 10上使用Firefox。

小智 8

<link href='../Fonts/Reef/reef-webfont.woff' rel='stylesheet' type='text/css'> 您不能引用这样的字体。

@font-face{
font-family: Reef;
src: url('reef-webfont.woff'), url('reef-webfont.woff') format('woff');}
Run Code Online (Sandbox Code Playgroud)

将字体放在此样式文件所在的目录中