とりあえず、簡単なのを作ってみよう。
1 2 3 4 |
<div class="animation-test"> <div class="box1"></div> <div class="box2"></div> </div> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
.animation-test{ position:relative; width: 100%; height: 300px; } .box1{ animation: ani1 5s ease 1s infinite alternate; -moz-animation: ani1 5s ease 1s infinite alternate; -webkit-animation: ani1 5s ease 1s infinite alternate; -o-animation: ani1 5s ease 1s infinite alternate; -ms-animation: ani1 5s ease 1s infinite alternate; } .box2{ position:absolute; border-radius:30px; width: 30px; height: 30px; top:50px; animation: ani2 3s ease 1s infinite alternate; -moz-animation: ani2 3s ease 1s infinite alternate; -webkit-animation: ani2 3s ease 1s infinite alternate; -o-animation: ani2 3s ease 1s infinite alternate; -ms-animation: ani2 3s ease 1s infinite alternate; } @keyframes ani1 { 0% {width: 50px; height: 50px; background: #000;} 100% {width: 150px; height: 150px; background: #ccc;} } @keyframes ani2 { 0% {left:300px; background: #000;} 100% {left:150px; background: #f00;} } |