teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

1

先ほどは誤って途中確定した為、編集いたしました。

2018/03/13 03:52

投稿

退会済みユーザー
answer CHANGED
@@ -1,3 +1,9 @@
1
- メニューの中身を直接編集
1
+ メニューの中身を直接編集するのではなく「before」疑似要素セレクタを使って挿入するのが良いかと思います。
2
+ ```
2
- #sidebar h2::before { content:'\f146'; font-family:'Font Awesome 5 Pro'; color:#444; padding-right:4px; font-weight:400; }
3
+ #allow_change h2::before { content:url(閉じた時の画像.png); }
3
- #sidebar h2.collapsed::before { content:'\f0fe'; }
4
+ #allow_change h2.collapsed::before { content:url(開いた時の画像.png); }
5
+ ```
6
+ ※「:before」でも「::before」でも動作しますが、css3では「::before」が推奨されています。
7
+
8
+ 詳細は以下をご覧ください。
9
+ https://developer.mozilla.org/ja/docs/Web/CSS/::before