【CSS3リファレンス】animation-direction - web design lab
にほんブログ村 デザインブログ Webデザインへ PVアクセスランキング にほんブログ村

【CSS3リファレンス】animation-direction


【CSS3リファレンス】animation-direction

こんにちは(・∀・)

CSS3で新しく追加されたプロパティをご紹介します。今回ご紹介するCSSプロパティはanimation-directionです。

概要

アニメーションを繰り返す際、最後まで再生が終わった後に逆再生で戻すか、単純に最初まで戻って再生を繰り返し始めるかをanimation-directionプロパティを使用して設定する事ができます。


.sample {
  animation-direction: alternate;
}
適用要素

ブロックレベル要素・インライン要素

指定できる値
alternate
最後まで再生したら逆再生で戻るを繰り返す
normal
再生後最初に戻って繰り返し再生
初期値

normal

サンプル
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

大きさが変わります。


にほんブログ村 デザインブログ Webデザインへ PVアクセスランキング にほんブログ村