如何在网页上使用 Google Fonts?
Google Fonts 是一款免费的电脑和网页字体服务。它于 2010 年推出,由 Google 所有。2021 年增加了开源图标支持。它包含 1576 个字体家族,其中包括 352 个可变字体家族。Google Fonts 的官方网站是 fonts.google.com。就像 Font Awesome 图标一样,Google Fonts 是使用 <link> 元素添加到网站的。让我们看看如何在网页上添加和使用 Google Fonts。
功能
轻松在您的网页上插入 Google Fonts
它拥有超过 1000 个字体家族
选择字体时,请查看样本。
还提供了字体测试工具
直接下载任何字体家族
设置字体的链接
为了在我们的网页上添加字体,我们使用了 Google Fonts。使用 <link> 元素将其包含在网页中:
<link href="https://fonts.googleapis.ac.cn/css?family=Permanent+Marker&display=swap" rel="stylesheet"/>
在您的网页上包含 Google Fonts
要在您的页面上插入 Google Fonts,请使用 font-family 属性并在 <body> 元素下设置它:
<style>
body {
font-family: "Permanent Marker", cursive;
font-size: 22px;
}
</style>
示例
要在您的网页上使用 Google Fonts,代码如下:
<!DOCTYPE html>
<html>
<head>
<link href="https://fonts.googleapis.ac.cn/css?family=Permanent+Marker&display=swap" rel="stylesheet"/>
<style>
body {
font-family: "Permanent Marker", cursive;
font-size: 22px;
}
</style>
</head>
<body>
<h1>Google fonts example</h1>
<p>
Lorem ipsum dolor sit amet consectetur, adipisicing elit. Debitis non a quos repudiandae doloribus cumque! Ex rem rerum aut maiores.
</p>
<h2>1 2 3 4 5 6 7 8 9 10</h2>
</body>
</html>
广告
数据结构
网络
关系数据库管理系统 (RDBMS)
操作系统
Java
iOS
HTML
CSS
Android
Python
C 语言编程
C++
C#
MongoDB
MySQL
Javascript
PHP