【CSS3リファレンス】animation
こんにちは(・∀・)
CSS3で新しく追加されたプロパティをご紹介します。今回ご紹介しますCSSプロパティはanimationです。
概要
animationプロパティはアニメーションの個別設定を半角スペースで区切って順不同の一括で指定する事ができます。
@keyframes sample-anime {
0% { background-color: red; }
50% { background-color: blue; }
100% { background-color: yellow; }
}
.sample {
animation: sample-anime 2s linear infinite alternate 1s;
}
適用要素
ブロックレベル要素・インライン要素
指定できる値
animation-nameプロパティで指定する値
animation-durationプロパティで指定する値
animation-timing-functionプロパティで指定する値
animation-iteration-countプロパティで指定する値
animation-directionプロパティで指定する値
animation-delayプロパティで指定する値
初期値
個別プロパティの初期値
サンプル
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: demo-anime 2s linear infinite alternate 1s;
animation: demo-anime 2s linear infinite alternate 1s;
}
サンプルのCSSはVendor-Prefixを使用した例も載せてあります。
Result
大きさが変わります。