CSS 實現載入動畫之三-鋼琴按鍵

來源:互聯網
上載者:User

標籤:des   style   blog   http   color   io   os   使用   ar   

原文:CSS 實現載入動畫之三-鋼琴按鍵

今天做的這個動畫實現也是非常簡單,簡單數幾行代碼就可以搞定。給這個動畫取了個優雅的名字--鋼琴按鍵,也實在是想不出什麼更形象的名字了。廢話不多說,直接。

 

1. 先看gif圖

 

2. 代碼實現思路

2.1 定義五個方塊的元素。

2.2 對方塊元素使用動畫,延時改變透明度。

 

3. 主要使用的技術

主要用到了animation動畫

@-webkit-keyframes load{
  0%{opacity:1;}
  100%{opacity:0;}
}
.m-load2 .item{-webkit-animation:load 0.5s linear 0s infinite;}

 

4. 原始碼

 1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta http-equiv="Content-Type" Content="text/html; charset=utf-8;"> 5 <title>CSS3實現載入的動畫效果3</title> 6 <meta name="author" content="rainna" /> 7 <meta name="keywords" content="rainna‘s css lib" /> 8 <meta name="description" content="CSS3" /> 9 <style>10 *{margin:0;padding:0;}11 .m-load{background:url(‘load.gif‘) center center no-repeat;}12 13 .m-load,.m-load2{width:60px;height:10px;margin:100px auto;}14 15 /** 載入動畫的靜態樣式 **/16 .m-load2:before,.m-load2:after,.m-load2 .item{float:left;width:10px;height:10px;margin:0 2px 0 0;background:#444;}17 .m-load2:before,.m-load2:after{content:‘‘;}18 19 /** 載入動畫 **/20 @-webkit-keyframes load{21     0%{opacity:1;}22     100%{opacity:0;}23 }24 .m-load2:before{-webkit-animation:load 0.5s linear 0s infinite;}25 .m-load2 .item:nth-child(1){-webkit-animation:load 0.5s linear 0.1s infinite;}26 .m-load2 .item:nth-child(2){-webkit-animation:load 0.5s linear 0.2s infinite;}27 .m-load2 .item:nth-child(3){-webkit-animation:load 0.5s linear 0.3s infinite;}28 .m-load2:after{-webkit-animation:load 0.5s linear 0.4s infinite;}29 </style>30 </head>31 32 <body>33 <div class="m-load"></div>34 35 <div class="m-load2">36     <div class="item"></div>37     <div class="item"></div>38     <div class="item"></div>39 </div>40 </body>41 </html>

 

CSS 實現載入動畫之三-鋼琴按鍵

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.