CSS 实用工具: Google Fonts API 引入免费字体库

编程入门 行业动态 更新时间:2024-10-20 01:19:34

CSS 实用工具: Google Fonts API 引入免费字体库

文章目录

  • CSS 实用工具: Google Fonts API 引入免费字体库
  • 正文
    • 1. Google Fonts 使用
    • 2. 在代码中引入字体 & 效果
  • 其他资源
    • 参考连接
    • 完整代码示例

正文

今天给大家分享一个有趣的工具,写 Web 的时候常常找不到有什么字体是好看的或是要一直去找。本篇将给大家介绍一个免费的字体库,由 Google 提供的 API

1. Google Fonts 使用

地址:https://fonts.google/

首先点击去上面那个网站

将会看到有很多字体可以选择,点进去你想要的字体

然后点击 select this style,你可以一次选中多个字体,然后在代码中一次导入

接下来在右侧选择 @import 复制下面的内容到 css 如下

@import url('https://fonts.googleapis/css2?family=Space+Mono&family=Trispace&family=Zen+Antique+Soft&display=swap');

2. 在代码中引入字体 & 效果

最后你就可以在你的 css 文件中使用想相关字体了

  • index.css
@import url('https://fonts.googleapis/css2?family=Space+Mono&family=Trispace&family=Zen+Antique+Soft&display=swap');

.font1 {
  font-family: 'Space Mono', monospace;
}

.font2 {
  font-family: 'Trispace', sans-serif;
}

.font3 {
  font-family: 'Zen Antique Soft', serif;
}
  • 效果

其他资源

参考连接

TitleLink
Google Fonts APIhttps://fonts.google/

完整代码示例

https://github/superfreeeee/Blog-code/tree/main/front_end/css/css_font_family_import

更多推荐

CSS 实用工具: Google Fonts API 引入免费字体库

本文发布于:2023-06-14 01:34:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1423347.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:实用工具   字体库   CSS   Google   API

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!