[英]Changing font-family in class
这是一个非常简单的问题,我想不出答案。 我是一个完全的初学者。 由于某种原因,我无法更改字体系列。 我可以实际输入不同的东西,但它根本不会改变字体。 这是我的代码的样子:
<!DOCUTYPE html>
<html>
<head>
<title>Fruit</title>
<meta http-equiv="Content-Type" content="text/html"; charset="utf-8"/>
<style>
.left {
width:800px;
margin:auto;
text-align:center;
box-sizing:border-box;
background-color:#FFEBCD;
border:2px solid black;
font-family: 'Alegreya SC';font-size: 22px;
}
</style>
</head>
<body>
<div class="left">
<h1><strong>Fruit</strong></h1>
</body>
</html>
您需要在项目中包含所需的字体(在您的情况下为 google 字体)。 您可以通过多种方式做到这一点。 一种是在 HTML 中添加指向它的链接
你也可以快速浏览一下这个文档
其他方法:
使用@import url('https://fonts.googleapis.com/css2?family=Alegreya+SC');
在您的样式表 (CSS) 中导入@import url('https://fonts.googleapis.com/css2?family=Alegreya+SC');
或者
下载字体并将其包含在您的项目中,然后将其导入
与@import(pathToFont)
.left { width:800px; margin:auto; text-align:center; box-sizing:border-box; background-color:#FFEBCD; border:2px solid black; font-family: 'Alegreya SC', serif; font-size: 22px; }
<link href="https://fonts.googleapis.com/css2?family=Alegreya+SC&display=swap" rel="stylesheet"> <div class="left"> <h1> AAAA </h1> </div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.