1
通过 CDN 引入

将以下代码添加到 <head> 中,即可使用 FontAwesome 5 的 1,500+ 图标。v5 首次引入多风格支持(Solid/Regular/Brands),CDN 方式一行代码即可完成集成。

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/[email protected]/css/all.min.css">
<link rel="stylesheet" href="https://cdn.staticfile.net/font-awesome/5.15.4/css/all.min.css">
2
通过 npm 安装

在项目中以 npm 依赖方式引入 FontAwesome 5:

npm install @fortawesome/[email protected]

在 Webpack 或 Vite 项目中,安装后可直接在 JavaScript/TypeScript 中 import '@fortawesome/fontawesome-free/css/all.min.css',构建工具会自动处理样式注入。

3
基础使用

FontAwesome 5 使用 fas/far/fab 前缀(v5 早期版本),图标名称与 v4 有较大差异:

<i class="fas fa-home"></i> <i class="far fa-user"></i> <i class="fab fa-github"></i>
4
图标样式控制
<i class="fas fa-camera fa-lg"></i> <i class="fas fa-camera fa-2x"></i> <i class="fas fa-camera fa-3x"></i> <i class="fas fa-spinner fa-spin"></i> <i class="fas fa-heart" style="color:red"></i>

进阶资源

使用指南

深入了解 FontAwesome 的各种使用技巧、动画效果和最佳实践。

查看指南
实操教程

通过实际项目案例学习 FontAwesome 的完整使用流程和代码示例。

查看教程
速查表

快速查找类名、尺寸、动画效果、版本前缀等常用参考信息。

查看速查表
分享

相关推荐