トップページ  > CSS3  > animation-name

★CSS3リファレンス

animation-name …… アニメーション名を指定する
Firefox Google Chrome2(-webkit-)Google Chrome3(-webkit-)Google Chrome4(-webkit-)Google Chrome5(-webkit-)Google Chrome6(-webkit-) Safari4(-webkit-)Safari5(-webkit-)
広告

animation-nameプロパティは、要素にキーフレームアニメーションを適用する場合の、 アニメーション名を指定する際に使用します。

animation系プロパティで要素にキーフレームアニメーションを適用する際には、@keyframesルールでキーフレームを定義する必要があります。 キーフレームでは、アニメーション開始時点(0%)のスタイルと終了時点(100%)、 さらに、必要に応じてその進行途中(0~100%)のスタイルを指定します。

animation-nameプロパティでアニメーション名を指定すると、@keyframesルールで定義したキーフレームが選択されます。 それにより、アニメーション効果を与える色・サイズなどのスタイルと、 アニメーション効果の適用方法(時間・進行割合・繰り返し回数・反転再生・一時停止・いつ始まるか)が関連付けられます。

animation-nameプロパティの初期値はnoneですが、この場合にはアニメーションは実行されません。 また、指定したアニメーション名がどのキーフレームにも存在しない場合もアニメーションは実行されません。

■値

none
アニメーション効果を指定しない(初期値)
アニメーション名
カンマ( , )区切りでアニメーション名のリストを指定する

■初期値・適用対象・値の継承

初期値
none
適用対象
すべての要素、:before疑似要素、:after疑似要素
値の継承
しない

■使用例

CSSソースは外部ファイル(sample.css)に記述

div.sample {
animation-name: anime1;
animation-duration: 5s;
animation-timing-function: ease;
animation-iteration-count: infinite;
}

@keyframes anime1 {
0% {width: 50px; height: 50px; background-color: aqua;}
100% {width: 200px; height: 50px; background-color: blue;}
}

HTMLソース

<html>
<head>
<link rel="stylesheet" href="sample.css" type="text/css">
</head>
<body>
<div class="sample">animation効果のサンプル</div>
</body>
</html>
↓↓↓

ブラウザ上の表示

animation効果のサンプル

■ベンダープレフィックスを付けた場合の使用例

CSSソースは外部ファイル(sample.css)に記述

div.prefix_sample {
-moz-animation-name: anime1;
-moz-animation-duration: 5s;
-moz-animation-timing-function: ease;
-moz-animation-iteration-count: infinite;

-webkit-animation-name: anime1;
-webkit-animation-duration: 5s;
-webkit-animation-timing-function: ease;
-webkit-animation-iteration-count: infinite;

-o-animation-name: anime1;
-o-animation-duration: 5s;
-o-animation-timing-function: ease;
-o-animation-iteration-count: infinite;

-ms-animation-name: anime1;
-ms-animation-duration: 5s;
-ms-animation-timing-function: ease;
-ms-animation-iteration-count: infinite;
}

@-moz-keyframes anime1 {
0% {width: 50px; height: 50px; background-color: aqua;}
100% {width: 200px; height: 50px; background-color: blue;}
}

@-webkit-keyframes anime1 {
0% {width: 50px; height: 50px; background-color: aqua;}
100% {width: 200px; height: 50px; background-color: blue;}
}

@-o-keyframes anime1 {
0% {width: 50px; height: 50px; background-color: aqua;}
100% {width: 200px; height: 50px; background-color: blue;}
}

@-ms-keyframes anime1 {
0% {width: 50px; height: 50px; background-color: aqua;}
100% {width: 200px; height: 50px; background-color: blue;}
}

HTMLソース

<html>
<head>
<link rel="stylesheet" href="sample.css" type="text/css">
</head>
<body>
<div class="prefix_sample">animation効果のサンプル</div>
</body>
</html>
↓↓↓

ブラウザ上の表示

animation効果のサンプル
広告
Sponsors
広告
MuuMuu Domain!
ドメイン取るならお名前.com
現役エンジニアのオンライン家庭教師【CodeCamp】
サイトに広告を掲載してお小遣いが稼げる!【A8.net】
Node.jsコース
はじめてのプログラミングコース
▲ページ先頭へ
HTMLクイックリファレンスについて
© HTMQ