CSSアイコン
アイコンライブラリを使用すると、HTMLページにアイコンを簡単に追加できます。
アイコンを追加する方法
HTMLページにアイコンを追加する最も簡単な方法は、FontAwesomeなどのアイコンライブラリを使用することです。
指定したアイコンクラスの名前を任意のインラインHTML要素(<i>
またはなど
<span>
)に追加します。
以下のアイコンライブラリのすべてのアイコンは、CSS(サイズ、色、影など)でカスタマイズできるスケーラブルなベクトルです。
FontAwesomeアイコン
Font Awesomeアイコンを使用するには、
fontawesome.com<head>
にアクセスしてサインインし、 HTMLページのセクションに追加するコードを取得します。
<script src="https://kit.fontawesome.com/yourcode.js" crossorigin="anonymous"></script>
Font Awesome 5チュートリアルで、FontAwesomeの使用を開始する方法の詳細をお読み ください。
注:ダウンロードやインストールは必要ありません!
例
<!DOCTYPE html>
<html>
<head>
<script src="https://kit.fontawesome.com/a076d05399.js" crossorigin="anonymous"></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>
結果:
すべてのFontAwesomeアイコンの完全なリファレンスについては、アイコンリファレンスにアクセスしてください。
ブートストラップアイコン
Bootstrapグリフィコンを使用するに<head>
は、HTMLページのセクション内に次の行を追加します。
<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アイコンを使用するに<head>
は、HTMLページのセクション内に次の行を追加します。
<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>
結果:
すべてのアイコンの完全なリストについては、 アイコンチュートリアルにアクセスしてください。