【发布时间】:2016-04-22 10:39:42
【问题描述】:
我是网络开发新手,所以请原谅我的无知...
我正在尝试在我的网站上放置自定义字体。我试过用@font-face 和谷歌字体来做,但似乎没有任何效果。
我(希望)在 HTML 文档的顶部链接了 google 字体。还链接了包含“shewalks”字体的 fonts.css。 CSS 文件显示了我如何尝试使用 @font-face 链接字体。
我做错了吗?
CSS:
@font-face {
font-family: 'shewalks';
src: url('./fonts/she_always_walks_alone_demo-webfont.ttf');
src: url('./fonts/she_always_walks_alone_demo-webfont.woff');
src: url('./fonts/she_always_walks_alone_demo-webfont.svg');
src: url('./fonts/she_always_walks_alone_demo-webfont.eot');
src: url('./fonts/she_always_walks_alone_demo-webfont.woff2');
}
a {
font-family:'pacifico',verdana,arial;
}
h2 {
font-family: 'Pacifico', cursive;
}
body {
text-align: center;
font-family: 'shewalks';
}
header {
position: fixed;
background: #ffffff;
width: 100%;
z-index: 10;
position: fixed;
height: 300px;
}
html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link href='https://fonts.googleapis.com/css?family=Pacifico' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="fonts/fonts.css" />
<link href="style.css" rel="stylesheet" />
<title>Me and the Monster</title>
</head>
<body>
<div id="banner">
<h2>Me and the Monster</h2>
</div>
<div id="content">
<h2><div style="font-family: 'pacifico', serif;">This should be in 'pacifico' font.</div></h2>
<p>Content goes here </p>
<p>Content goes here </p>
</div>
非常感谢您的任何帮助!
【问题讨论】:
-
您的字体导入
<link href='https://fonts.googleapis.com/css?family=Pacifico'缺少结束标记。应该是<link href='https://fonts.googleapis.com/css?family=Pacifico' rel='stylesheet' type='text/css'>