目次
ボタンに自然な動きをつけるアニメーション
transitionプロパティを使えば、ホバー時などのスタイル変更にアニメーション効果をつけられます。ちょっとした動きが加わるだけで印象が良くなります。
HTML
1 2 3 |
<a href="#" class="button">ボタンサンプル</a> |
基本CSS
1 2 3 4 5 6 7 8 9 10 11 |
.button { background: #3498db; color: #fff; transition: background 0.3s ease; } .button:hover { background: #2980b9; } |
複数プロパティを滑らかに変化
1 2 3 4 5 |
.button { transition: all 0.3s ease; } |
easeのほか、linearやease-in-outなどの指定が可能です。
アニメーションしたいプロパティのみを明示するのが基本となります。