我在Angular项目的styles.css文件中添加了导入Google字体的链接.就这个:
@import url('https://fonts.googleapis.com/css?family=Muli:400,700');
Run Code Online (Sandbox Code Playgroud)
Noe如何在我的项目中全局应用字体,以及如何将其添加到html元素中,例如for.
Z. *_*ley 18
使用谷歌字体的最佳方法是在index.html文件的<head>...</head>部分中包含脚本include .当你深入研究Google作为你的朋友时,你会发现最好的部分之一是他们的cdn是以这种方式支持的!
等效的脚本包括:
<link href="https://fonts.googleapis.com/css?family=Muli:400,700" rel="stylesheet">
这与Google的Material - Icons的工作方式类似!
要在样式表中使用它,请将其包含在基本styles.css文件中:
html, body {
font-family: 'Muli';
}
Run Code Online (Sandbox Code Playgroud)
注意:你会发现css标签"font-family"实际上有很多选项.这是最基本的,但如果您想了解更多信息,我很乐意更新答案以便更具体.我想尽力去理解你的问题,解决它,我们可以一起深入了解这个问题.
Ple*_*rds 11
另一件好事是将字体下载到您的服务器。这样,您创建的 Intranet 应用程序无需获取外部资源即可正常运行。在我国的投票机构中,我们在选举日切断了与服务器的连接以避免黑客攻击,因此应用程序必须在本地拥有所需的所有资产:
$ npm install --save typeface-muli
Run Code Online (Sandbox Code Playgroud)
在 angular.json 中添加:
"styles": [
"src/styles.scss",
"node_modules/typeface-muli/index.css" <-- add this line
],
Run Code Online (Sandbox Code Playgroud)
从 index.html 中删除:
<!-- <link href="https://fonts.googleapis.com/css?family=Muli:300,400,600,700" rel="stylesheet"> -->
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10534 次 |
| 最近记录: |