1
1

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.

Font Awesomeをバージョンアップしたらチェックボックスが消えた時の対処法

Last updated at Posted at 2019-07-29

問題

FontAwesomeのバージョンを4系から5系にあげる際、疑似要素に指定していたFontAwesomeのアイコンが表示されなくなってしまった。

解決方法

5系では-oという接尾辞が使えなくなっているため別のアイコンを使用する

4系で使用していたCheckBox
'\f096' (fa-square-o)
Kobito.gWFd5A.png

'\f14a'(check-square)
Kobito.uE816T.png

5系で仕様が変わってしまったためバージョンアップすると未チェックのボタン'\f096'が表示されなくなる

そのため新しい'\f0c8'を使う必要がある。

しかしそのままするだけだとデフォルトでSolidになってしまうようで、未チェックでも塗りつぶしになりチェックしているのかどうかがわかりずらいものになる。

'\f0c8'(square) solid
Kobito.2cgHcY.png

そのためfont-weightでnormalと指定

  &-checkbox {
    .input+label::before,
    input+label::before {
      font-weight: normal;
      content: '\f0c8';
    }
    .input.checked+label::before,
    input:checked+label::before {
      font-weight: bold;
      content: '\f14a';
    }
  }

Kobito.QFHas2.png

上の画像のようにわかりやすくなった。

1
1
0

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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?