【CSS3リファレンス】animation-name
こんにちは(・∀・)
CSS3で新しく追加されたプロパティをご紹介します。今回ご紹介するCSSプロパティはanimation-nameです。
概要
animation-nameプロパティを使用してアニメーションの名前を指定する事ができます。カンマで区切って複数の名前を指定する事もできます。
@keyframes sample-anime {
0% { background-color: red; }
50% { background-color: blue; }
100% { background-color: yellow; }
}
.sample {
animation-name: sample-anime;
}
適用要素
ブロックレベル要素・インライン要素
指定できる値
- キーフレームの名前
- キーフレームの名前を指定
- none
- アニメーションは実行されない
初期値
none
サンプル
HTML
<p class="demo">
大きさが変わります。
</p>
CSS
@-webkit-keyframes demo-anime {
0% { width: 250px; }
50% { width: 150px; }
100% { width: 300px; }
}
@keyframes demo-anime {
0% { width: 250px; }
50% { width: 150px; }
100% { width: 300px; }
}
.demo {
-webkit-animation-name: demo-anime;
-webkit-animation-duration: 2s;
-webkit-animation-timing-function: linear;
-webkit-animation-iteration-count: infinite;
-webkit-animation-direction: alternate;
-webkit-animation-delay: 1s;
animation-name: demo-anime;
animation-duration: 2s;
animation-timing-function: linear;
animation-iteration-count: infinite;
animation-direction: alternate;
animation-delay: 1s;
}
サンプルのCSSはVendor-Prefixを使用した例も載せてあります。
Result
大きさが変わります。