实例 使用了简写的动画 animation 属性
与前面的动画相同,但是使用了简写的动画 animation 属性:
div
{
animation: myfirst 5s linear 2s infinite alternate;
/* Firefox: */
-moz-animation: myfirst 5s linear 2s infinite alternate;
/* Safari 和 Chrome: */
-webkit-animation: myfirst 5s linear 2s infinite alternate;
/* Opera: */
-o-animation: myfirst 5s linear 2s infinite alternate;
}
$v.lab.setValue({ active:'css', html:' <!DOCTYPE HTML>\n
\n
\n \n \n注释:本例在 Internet Explorer 中无效。
\n\n \n \n', css:' div\n {\n width:100px;\n height:60px;\n background:red;\n position:relative;\n animation:myfirst 5s linear 2s infinite alternate;\n / Firefox: /\n -moz-animation:myfirst 5s linear 2s infinite alternate;\n / Safari and Chrome: /\n -webkit-animation:myfirst 5s linear 2s infinite alternate;\n / Opera: /\n -o-animation:myfirst 5s linear 2s infinite alternate;\n }\n
@keyframes myfirst\n {\n 0% {background:red; left:0px; top:0px;}\n 25% {background:yellow; left:200px; top:0px;}\n 50% {background:blue; left:200px; top:200px;}\n 75% {background:green; left:0px; top:200px;}\n 100% {background:red; left:0px; top:0px;}\n }\n
@-moz-keyframes myfirst / Firefox /\n {\n 0% {background:red; left:0px; top:0px;}\n 25% {background:yellow; left:200px; top:0px;}\n 50% {background:blue; left:200px; top:200px;}\n 75% {background:green; left:0px; top:200px;}\n 100% {background:red; left:0px; top:0px;}\n }\n
@-webkit-keyframes myfirst / Safari and Chrome /\n {\n 0% {background:red; left:0px; top:0px;}\n 25% {background:yellow; left:200px; top:0px;}\n 50% {background:blue; left:200px; top:200px;}\n 75% {background:green; left:0px; top:200px;}\n 100% {background:red; left:0px; top:0px;}\n }\n
@-o-keyframes myfirst / Opera /\n {\n 0% {background:red; left:0px; top:0px;}\n 25% {background:yellow; left:200px; top:0px;}\n 50% {background:blue; left:200px; top:200px;}\n 75% {background:green; left:0px; top:200px;}\n 100% {background:red; left:0px; top:0px;}\n }\n ' });