学习 Icons 字体图标 教程

创建于 2024-11-21 / 538
字体: [默认] [大] [更大]
❮ 首页 下一节 ❯

如何添加字体图标

要插入图标,请将图标类的名称添加到任何内联 HTML 元素中。

使用 <i><span> 元素被广泛用于添加图标。

下面图标库中的所有图标都是可缩放的矢量图标,可以使用CSS(大小、颜色、阴影等)进行自定义。


Font Awesome 5 图标

要使用免费 Font Awesome 5 图标,请访问 fontawesome.com 并注册登录以获取在网页中使用的代码。

关于如何开始使用Font Awesome 5 图标,请访问 Font Awesome 5 一章。

注释: Font Awesome 5 图标无需下载或安装!

实例

<!DOCTYPE html>
<html>
<head>
<script src="https://kit.fontawesome.com/yourcode.js"></script>
<!--Get your code at fontawesome.com-->
</head>
<body>

<i class="fas fa-band-aid"></i>
<i class="fas fa-cat"></i>
<i class="fas fa-dragon"></i>
<i class="far fa-clock"></i>
<i class="fas fa-clock"></i>

</body>
</html> 亲自试一试 »

Font Awesome 4 图标

要使用 Font Awesome 4 图标,请在 HTML 页面的 <head> 部分添加以下行:

注释: Font Awesome 4 图标无需下载或安装!

实例

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>

<i class="fa fa-cloud"></i>
<i class="fa fa-heart"></i>
<i class="fa fa-car"></i>
<i class="fa fa-file"></i>
<i class="fa fa-bars"></i>

</body>
</html> 亲自试一试 »

Bootstrap 3 图标

要使用 Bootstrap 3 图标,请在 HTML 页面的 <head> 部分添加以下行:

注释: Bootstrap 3 图标无需下载或安装!

实例

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://www.w3ccoo.com/lib/bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<body>

<i class="glyphicon glyphicon-cloud"></i>
<i class="glyphicon glyphicon-remove"></i>
<i class="glyphicon glyphicon-user"></i>
<i class="glyphicon glyphicon-envelope"></i>
<i class="glyphicon glyphicon-thumbs-up"></i>

</body>
</html> 亲自试一试 »

注释: Bootstrap 4 中不支持 Glyphicons。

有关 Bootstrap 3 和 Glyphicons 的更多信息,请访问我们的 Bootstrap 3 教程


Google 图标

要使用 Google 谷歌图标,请在 HTML 页面的 <head> 部分添加以下行:

注释: Google 谷歌图标无需下载或安装!

实例

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="/fonts/icon.asp?family=Material+Icons">
</head>
<body>

<i class="material-icons">cloud</i>
<i class="material-icons">favorite</i>
<i class="material-icons">attachment</i>
<i class="material-icons">computer</i>
<i class="material-icons">traffic</i>

</body>
</html> 亲自试一试 »

有关所有图标的完整列表 (font awesome, bootstrap 和 google),请访问 图标参考手册



0 人点赞过