アニメーションのキーフレームを定義します。
@keyframes:
Sample
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Language" content="ja" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="imagetoolbar" content="no" />
<title>@keyframes</title>
<link rel="stylesheet" type="text/css" href="/content/lib/global.css" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script type="text/javascript" src="./js/jquery.vendorprefix.js"></script>
<script type="text/javascript">
$(function(){
$("#rgrp input[type=radio]").click(function(){
var val=this.value;
var prefix=$.fn.VendorPrefix();
var rint = Math.round(0xffffff * Math.random());
var rgb='rgb(' + (rint >> 16) + ',' + (rint >> 8 & 255) + ',' + (rint & 255) + ')';
$("#sample").find("p").remove();
var $obj=$("<p>Sample</p>").appendTo("#sample");
$obj.css("background-color",rgb);
$obj.css(prefix+"animation-name",val);
$obj.css("animation-name",val);
});
});
</script>
<style type="text/css">
#sample {
width:500px; height:300px;
background:#eee;
}
#sample p {
margin:0; padding:0;
width:100px; height:100px;
background:#ccc;
position:relative;
animation:myani 3s linear 1s infinite alternate; /* CSS3 */
-moz-animation:myani 3s linear 1s infinite alternate; /* Firefox */
-webkit-animation:myani 3s linear 1s infinite alternate; /* Chrome, Safari */
-ms-animation:myani 3s linear 1s infinite alternate; /* IE */
-o-animation:myani 3s linear 1s infinite alternate; /* Opera */
}
@keyframes myani {
from {left:0px;}
to {left:400px;}
}
@-moz-keyframes myani {
from {left:0px;}
to {left:400px;}
}
@-webkit-keyframes myani {
from {left:0px;}
to {left:400px;}
}
@-ms-keyframes myani {
from {left:0px;}
to {left:400px;}
}
@-o-keyframes myani {
from {left:0px;}
to {left:400px;}
}
@keyframes myani2 {
0% {left:0px;}
25% { left:300px; }
50% { left:200px; top:200px; }
75% { left:400px; top:100px; }
100% {left:0px;}
}
@-moz-keyframes myani2 {
0% {left:0px;}
25% { left:300px; }
50% { left:200px; top:200px; }
75% { left:400px; top:100px; }
100% {left:0px;}
}
@-webkit-keyframes myani2 {
0% {left:0px;}
25% { left:300px; }
50% { left:200px; top:200px; }
75% { left:400px; top:100px; }
100% {left:0px;}
}
@-ms-keyframes myani2 {
0% {left:0px;}
25% { left:300px; }
50% { left:200px; top:200px; }
75% { left:400px; top:100px; }
100% {left:0px;}
}
@-o-keyframes myani2 {
0% {left:0px;}
25% { left:300px; }
50% { left:200px; top:200px; }
75% { left:400px; top:100px; }
100% {left:0px;}
}
</style>
<link rel="stylesheet" type="text/css" href="/common/css/example.css"></head>
<body id='example3' class='example'><div class="ads" style="margin:32px auto;text-align:center;"></div><h1 class='h'><a href='/'>PHP & JavaScript Room</a> :: 設置サンプル</h1>
<h3 class='h'>実行結果</h3>
<div id="wrap">
<h1>設置サンプル</h1>
<h2>@keyframes</h2>
<p>アニメーションのキーフレームを定義します。</p>
<!-- CODE -->
<p id="rgrp">
@keyframes:
<label for="r1"><input type="radio" name="r" id="r1" value="myani" checked="checked">myani</label>
<label for="r2"><input type="radio" name="r" id="r2" value="myani2">myani2</label>
</p>
<div id="sample">
<p>Sample</p>
</div>
<!-- CODE / -->
</div>
</body>
</html>