利用transition實現文字上下抖動的效果,transition抖動

來源:互聯網
上載者:User

利用transition實現文字上下抖動的效果,transition抖動

實現思路

通過改變字母的top值

每個字母不能同時運動,通過延遲時間,for迴圈  2s (i*50)ms ...

infinite  動畫會無限次地迴圈播放。

alternate  播放次數是奇數時,動畫向原方向播放;播放次數是偶數時,動畫向反方向播放

靜態

執行個體代碼

<!DOCTYPE html><html><head><meta charset="utf-8"><title></title><style type="text/css">@keyframes move{0%{top: 0;}100%{top: 10px;}}@-webkit-keyframes move{0%{top: 0;}100%{top: 10px;}}#box {width: 200px;height: 100px;background: red;font-size: 20px;color: #fff;}#box span {position: relative;/*animation: .2s move linear infinite alternate; */}</style><script>window.onload = function() {var span = document.querySelectorAll('#box span');for(var i = 0; i < span.length; i++){span[i].style.WebkitAnimation = span[i].style.animation = " .2s "+(i*50)+"ms move linear infinite alternate";}};</script></head><body><div id="box"><span>L</span><span>o</span><span>a</span><span>d</span><span>i</span><span>n</span><span>g</span></div></body></html>

總結

以上就是這篇文章的全部內容了,希望本文的內容對大家的學習或者工作能帶來一定的協助,如果有疑問大家可以留言交流。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.