如何在我的网站中使用字体

时间:2013-07-12 13:57:49

标签: html css fonts

我正在尝试在我的网站上使用某些字体但它生效了。 我为我网站的字体创建了一个文件夹,并在文件夹中添加了字体...... .ttf files

然后在css文件中我添加了这个:

@font-face {
font-family: Lato;
src: url(http://www.types4u.org/n/font/Lato.ttf) format("truetype");
font-family: Arbutus;
src: url(http://www.types4u.org/n/font/Arbutus.ttf) format("truetype");
font-family: Actor;
src: url(http://www.types4u.org/n/font/Actor.ttf) format("truetype");
font-family: LeagueGothic;
src: url(http://www.types4u.org/n/font/LeagueGothic.ttf) format("truetype");
font-family: LibreBaskerville;
src: url(http://www.types4u.org/n/font/LibreBaskerville.ttf) format("truetype");
}

Site Here

1 个答案:

答案 0 :(得分:1)

您确定以后要设置字体吗?您发布的代码将使您可以使用这些字体,但除非您告诉它,否则它不会使用它们。假设你已经完成了并且仍未显示,我很想将Google FontsGoogle Fonts API一起使用。因此,对于Lato字体,您将包括

<link href='http://fonts.googleapis.com/css?family=Lato' rel='stylesheet' type='text/css'>

在HTML的<head>中。然后,要使h1具有该字体,您只需要

h1 {
  font-family: 'Lato', sans-serif;
}

至少,这就是我认为你在问的问题。如果您可以更具体或提供更多上下文/代码,您可能会有更多人帮助您。