LoginSignup
1
0

More than 3 years have passed since last update.

CSS hover でアイコンが変わるボタン

Last updated at Posted at 2020-05-26

ボタンのホバーエフェクトを試行錯誤していたところ、なかなかいい表現かもと思ったので、書きました。

アイコン付きのボタンをホバーすると、アイコンが変わる、というものです。

デモの様子

hover_effected_btn.gif

実際のデモはこちら

使ったアイコン

CodePen 用に CDN 経由で使えるものを選択しただけなので、もちろん他でも :ok: です。

ポイント

  • ボタン要素の ::after にアイコンを指定
a.button-with-icons::after {
  font-family: 'Material Icons';
  content: '\e038';
  /* 中略 */
}
  • ボタン要素の :hover::after にもアイコンを指定
a.button-with-icons:hover::after {
  font-family: 'Material Icons';
  content: '\e87d';
}

デモで書いたコードは こちら です。

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