【发布时间】:2015-12-03 00:32:27
【问题描述】:
我在 .otf 文件中有几个自定义字体:
我的 index.html 文件如下所示:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>My Website</title>
<link rel="stylesheet" href="css/style.css" >
</head>
<body>
<h3 style = "font-family: customBold;">Hello</h3>
<h3 style = "font-family: customLight;">Hello</h3>
<h3 style = "font-family: customRegular;">Hello</h3>
<h3 style = "font-family: customThin;">Hello</h3>
</body>
</html>
我的 style.css 是这样的
@font-face {
font-family: customBold;
src: url(fonts/Custom-Bold.otf);
}
@font-face {
font-family: customLight;
src: url(fonts/Custom-Light.otf);
}
@font-face {
font-family: customRegular;
src: url(fonts/Custom-Regular.otf);
}
@font-face {
font-family: customThin;
src: url(fonts/Custom-Thin.otf);
}
但是,h3 的字体不会改变。
我跟着这个:
【问题讨论】:
-
你把所有字体文件都放到css/fonts文件夹了吗?
-
如果您为浏览器使用调试器,您将看到任何错误/丢失文件等。给开发者的好建议。
-
index.html 和 style.css 位于项目主目录中。里面还有另一个名为“fonts”的目录,其中包含 .otf 文件?