2011-09-10 14 views

答えて

4

もちろん、これを行うにはキーフレームアニメーションを使用する必要があります。ここでは簡単な例です:

HTML:

<div class="bounce"></div> 

CSS:

@-webkit-keyframes hop { 
     from{ 
     -webkit-transform: translate(0px,0px); 
     } 


     to { 
     -webkit-transform: translate(0px,-30px); 
     } 
     } 

@-moz-keyframes hop { 
     from{ 
     -moz-transform: translate(0px,0px); 
     } 


     to { 
     -moz-transform: translate(0px,-30px); 
     } 
     } 

.bounce{ 
    display:block; 
    height:200px; 
    width:200px; 
    background:#ff6600; 
    border-radius:300px; 
    margin-top:100px; 
-webkit-animation-name: hop; 
    -webkit-animation-duration:.3s; 
    -webkit-animation-direction:alternate; 
    -webkit-animation-timing-function:linear; 
    -webkit-animation-delay:0s; 
    -webkit-animation-iteration-count:infinite; 
    -moz-animation-name: hop; 
    -moz-animation-duration:.3s; 
    -moz-animation-direction:alternate; 
    -moz-animation-timing-function:linear; 
    -moz-animation-delay:0s; 
    -moz-animation-iteration-count:infinite; 
} 

そして、あなたの視聴喜びのためにフィドル:http://jsfiddle.net/hpBhf/1/

+0

素敵な作品! CSS3の岩! (ただし、jQueryアニメーションはさらに柔軟性があり、より簡単です)。D – Abraham

+1

これらのプロパティはすべて必要ありません。代わりにアニメーションの短縮形を使用すると、10行だけ縮小されます。 –

+0

私は知っていますが、誰かがアニメーションのプロパティをすべて知っていないと、完全に書き出された場合に起こっていたことを理解するのが簡単になると思いました。 – DuMaurier

関連する問題