20
19

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

FontAwesomeのiconをulやolのlist-styleに使う方法

Posted at

FontAwesomeのiconをulやolのlist-styleに使いたくなることってありますよねー。
残念ながら、list-styleに直接アイコンを使うことは出来ないのですが、以下の方法を使えば、同じようなことが実現できます。

HTML

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
(中略)
<ul>
  <li>人間失格</li>
  <li>斜陽</li>
  <li>ヴィヨンの妻</li>
</ul>

CSS

ul {
  list-style: none;
}
li:before {
  font-family: FontAwesome;
  content: '\f054'; /* アイコンのunicode */
}

li:beforeに設定するcontentにはバックスラッシュに続けて、FontAwesomeサイトのアイコン詳細ページ(上の例だとここ)に描かれてるUnicodeの値を書きます。

デモで実際にどうなるか御覧ください。

20
19
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
20
19

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?