我需要将段落的字体更改为特定字体,我的字体在ttf文件中。所有内容都是本地的(下载到我的网站文件夹中)。这是我的代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Unwritten</title>
<link rel="icon" href="cloak.png">
<style>
body {
margin-bottom: 200%;
background-image: url("site.png");
background-repeat: no-repeat;
background-size: cover;
}
#download_button {
position:absolute;
transition: .5s ease;
top: 50%;
left: 50%;
background-color: transparent;
background-repeat:no-repeat;
border: none;
cursor:pointer;
overflow: hidden;
outline:none;
font: "font.ttf";
}
</style>
</head>
<body>
<header>
<p class="buttons">This is in a font.<p>
</header>
<section>
</section>
<footer>
</footer>
</body>
答案 0 :(得分:0)
首先,你必须通过CSS导入你的字体:
@font-face {
font-family: 'FontName';
src: url('fontname.eot');
src: url('fontname?#iefix') format('embedded-opentype'),
url('fontname.svg#Locaweb-Icons') format('svg'),
url('fontname.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
然后,您可以使用它:
p.buttons {
font-family: 'FontName';
}