简体   繁体   English

在课堂上更改字体系列

[英]Changing font-family in class

This is a really simple question that I can't figure out the answer to.这是一个非常简单的问题,我想不出答案。 I am a total beginner.我是一个完全的初学者。 I can't change the font-family for some reason.由于某种原因,我无法更改字体系列。 I can physically type something different but it doesn't change the font at all.我可以实际输入不同的东西,但它根本不会改变字体。 This is what my code looks like:这是我的代码的样子:

<!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>

You need to include the desired font ( google font in your case ) inside your project.您需要在项目中包含所需的字体(在您的情况下为 google 字体)。 You can do that in multiple ways.您可以通过多种方式做到这一点。 One is adding a link to it in your HTML一种是在 HTML 中添加指向它的链接

You can also that a quick look at this documentation你也可以快速浏览一下这个文档

Other ways:其他方法:

  • import in your stylesheet (CSS) with @import url('https://fonts.googleapis.com/css2?family=Alegreya+SC');使用@import url('https://fonts.googleapis.com/css2?family=Alegreya+SC');在您的样式表 (CSS) 中导入@import url('https://fonts.googleapis.com/css2?family=Alegreya+SC'); or或者

  • download the font and include it in your project and then import it下载字体并将其包含在您的项目中,然后将其导入
    with @import(pathToFont)@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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM