我尝试使用@ font -face实现一个字体。
正如标题所暗示的,它不起作用,我也不知道为什么。
我使用的是最新版本的Firefox。
我确信路径是正确的。
编辑:
该文件夹如下所示:
main.html
main.css
**-字体
*- ProductSans
ProductSansRegular.ttf
ProductSansRegular.otf
*等。
@font-face {
font-family: "ProductSans";
src: url("fonts/ProductSans/ProductSansRegular.ttf") format("truetype"), url("fonts/ProductSans/ProductSansRegular.otf") format("opentype"), url("fonts/ProductSans/ProductSansRegular.woff2") format("woff2"), url("fonts/ProductSans/ProductSansRegular.woff") format("woff"), url("fonts/ProductSans/ProductSansRegular.eot") format("eot"), url("fonts/ProductSans/ProductSansRegular.svg") format("svg");
}
body {
font-family: "ProductSans";
}<head>
<meta charset="utf-8">
<link rel="stylesheet" href="main.css">
</head>
<body>
<div>
test
</div>
</body>发布于 2019-08-13 00:58:20
可能是因为你的链接有问题,所以你的字体没有加载。
fonts/.... 只有当您的fonts文件夹位于同一css目录中时才有效。
如果您的文件夹在css文件夹之外,并且位于项目的主文件夹中,则必须使用相对路径,因此您的所有链接将如下所示:
"../fonts/ProductSans/ProductSansRegular.ttf"当你使用你的字体时,不要用双引号。
body {
font-family: ProductSans;
}https://stackoverflow.com/questions/57464605
复制相似问题