如何在HTML中设置FONT

时间:2017-12-01 16:45:38

标签: html

我的字体似乎无法正常工作,我做错了什么?

我在头部添加了谷歌字体。 它低于元。

我还添加了CSS代码。

我希望有人可以帮助我。



html {
	height: 100%;
}

body { 
	margin: 0px;
	height: 100%;
}

h1 { text-align: center; }

.hoofdtabel { 
	width: 100%;
	height: 100%;
    margin: 0px;
	border-collapse: collapse;
} /* Vervangt cellspacing="0" */

.kop { 
	width: 100%;
    height: 10%;
	background-color: 	#5570aa;
	text-align: center;
	font-size: 72px; 
}
			 
.menu { 
	width: 12%;
    height: 70%;
	padding: 5px;                   /* Vervangt cellpadding="5" */
	background-color: #9e6171;
	vertical-align: top; 
}

.inhoud { 
	width: 96%;
    height: 85%;
	padding: 5px;
	text-align: left;
	background-color: #b8c6c4;
	vertical-align: top; 
} 
					
.onder {
	width: 100%;
    height: 5%; 
	padding: 5px;
	background-color: black;
	vertical-align: middle;
	text-align: right;
	color: white;
}

.button {
	padding: 16px 32px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 16px;
    margin: 4px 2px;
    transition-duration: 0.4s;
    cursor: pointer;
	background-color: #e9ece5;
    color: black;
    border: 2px solid #b3c2bf;
    width: 100px;

}

.button:hover {
    background-color: #008CBA;
}

.frame {
	height: 100%;
	width: 100%;
	border: none;

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro" rel="stylesheet"> 
<title>Hi</title>
</head>
<body>

<div class="Hi">

 <h1>Hi</h1>
<font size="4" >
 <p>Hello all<br>


</font> 



</div>

</body>
</html>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:2)

您刚刚加载了字体,但忘了告诉哪个元素应该使用它。

在所有段落(在CSS文件中)使用它的示例:

p {
  font-family: "Source Sans Pro", sans-serif;
}

<强>更新

我认为你的代码应该是这样的:

的style.css:

html {
    height: 100%;
}

body { 
    margin: 0px;
    height: 100%;
}

h1 { text-align: center; }

p {
  font-family: "Source Sans Pro", sans-serif;
}

... and the rest of the file, which you posted

的index.html:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro" rel="stylesheet"> 
<link href="style.css" rel="stylesheet"> 
<title>Hi</title>
</head>
<body>
<div class="Hi">

<h1>Hi</h1>
<font size="4">
 <p>Hello all<br><p>
</font>

</div>
</body>
</html>

在此之后, Hello all 文本应使用Source Sans Pro字体。

此外,您忘记在HTML文档中链接CSS文件(与链接Google字体的方法相同)。请参阅下面的google字体示例。