我尝试使用本地字体在 html 中应用样式,下面是代码。字体未应用于 harlow 类使用的元素
<!DOCTYPE html>
<html>
<head>
<style>
@font-face {
font-family: myFirstFont;
src:local("C:\Users\Website\fonts\Harlow_Solid_Italic.ttf");
}
.harlow{
font-family: myFirstFont;
}
</style>
</head>
<body>
<div>With CSS3, websites can finally use fonts other than the pre selected "web-safe" fonts.</div>
<p><b class="harlow">Note:</b> Internet Explorer 8 and earlier, do not support the @font-face rule with the WOFF format (only support for EOT format).</p>
</body>
</html>
原文由 anavaras lamurep 发布,翻译遵循 CC BY-SA 4.0 许可协议
我做了以下更改,我得到了结果
字体系列的引号
使用 URL 而不是本地
将“\”更改为“/”
注意: 使用
local
css 函数会在开发者控制台中引发错误,提示资源未加载。请参阅下面的修改后的代码。