Ikon CSS

Bagaimana menambah ikon

Yang paling mudah untuk menambah ikon ke halaman HTML adalah menggunakan pustaka ikon, seperti Font Awesome.

Tambahkan nama kelas ikon yang ditentukan ke setiap elemen HTML dalam baris (seperti <i> atau <span>).

Semua ikon di pustaka ikon di bawah adalah vektor yang dapat diperbesar, dan dapat disesuaikan menggunakan CSS (ukuran, warna, bayangan, dll).

Font Awesome Ikon

如需使用 Font Awesome 图标,请访问 fontawesome.com,登录并获取代码添加到 HTML 页面的 <head> 部分:

<script src="https://kit.fontawesome.com/yourcode.js"></script>

请在我们的 Font Awesome 5 教程中,阅读有关如何开始使用 Font Awesome 的更多内容。

提示:无需下载或安装!

实例

<!DOCTYPE html>
<html>
<head>
<script src="https://kit.fontawesome.com/a076d05399.js"></script>
</head>
<body>
<i class="fas fa-cloud"></i>
<i class="fas fa-heart"></i>
<i class="fas fa-car"></i>
<i class="fas fa-file"></i>
<i class="fas fa-bars"></i>
</body>
</html>

结果:

亲自试一试

Bootstrap 图标

如需使用 Bootstrap glyphicons,请在 HTML 页面的 <head> 部分内添加这行:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

提示:无需下载或安装!

实例

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/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>

结果:

亲自试一试

Google 图标

如需使用 Google 图标,请在HTML页面的 <head> 部分中添加以下行:

<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">

提示:无需下载或安装!

实例

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?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>

结果:

亲自试一试