css3載入ing動畫

来源:http://www.cnblogs.com/wmlucky/archive/2016/12/18/6195851.html
-Advertisement-
Play Games

項目中ajax交互成功前總會需要給用戶提醒,比如請稍候、正在載入中等等,那個等待的動圖以前項目中用的是gif,在移動端畫質很渣,有毛邊,於是在新項目中用css3展示載入中的動畫效果。 js放在項目公用里,樣式放到公用樣式里,調用的時候tipLoading(type,top,left),在ajax交互 ...


項目中ajax交互成功前總會需要給用戶提醒,比如請稍候、正在載入中等等,那個等待的動圖以前項目中用的是gif,在移動端畫質很渣,有毛邊,於是在新項目中用css3展示載入中的動畫效果。

function tipLoading(type,top,left){
    if($("arrorbox"))$('#arrorbox').remove();
    var dataType=[
        '<div class="sk-circle"><div class="sk-circle1 sk-child"></div><div class="sk-circle2 sk-child"></div><div class="sk-circle3 sk-child"></div><div class="sk-circle4 sk-child"></div><div class="sk-circle5 sk-child"></div><div class="sk-circle6 sk-child"></div><div class="sk-circle7 sk-child"></div><div class="sk-circle8 sk-child"></div><div class="sk-circle9 sk-child"></div><div class="sk-circle10 sk-child"></div><div class="sk-circle11 sk-child"></div><div class="sk-circle12 sk-child"></div></div>',
        '<div class="spinner"><div class="bounce1"></div><div class="bounce2"></div><div class="bounce3"></div></div>',
    ],
        html="<div class='tiploading'></div>", type = type || 0,
        top  = top  || "48%",
        left = left || "50%",
        timer= null;
    $("body").append(html);
    if($(".tiploading")){
        $(".tiploading").css({
            "margin-left": -20+"px",
            "left": left,
            "top": top
        });
        !type==1?$(".tiploading").append(dataType[type]+"<div class='tiploading-con'>請稍候</div>"):$(".tiploading").append(dataType[type]+"<div class='tiploading-con'></div>");
    }
}
function tipLoadingRemove(){
    if($(".tiploading")){
        $(".tiploading").remove();
    }
}

js放在項目公用里,樣式放到公用樣式里,調用的時候tipLoading(type,top,left),在ajax交互成功前調用,成功後調用tipLoadingRemove()移除,也可以加個超時,不過讓刪了,type現在只有兩種,網上有很多種,可以再加自己需要的,預設第一種0,傳個1就是第二種。top、left為位置。

css↓↓

/*2016-12-10 wm 載入樣式*/
.tiploading{width: 40px;height: 40px;background: rgba(0,0,0,.7);position:fixed;border-radius: 10px;z-index: 9999;}
.tiploading .tiploading-con{position:absolute;bottom:10px;left:0;width: 100%;height: 20px;line-height: 20px;font-size: 12px;color:#fff;text-align: center;}
/*type1*/
.sk-circle {width: 30px;height: 30px;position: relative;top:5px;left:5px;}
.sk-circle .sk-child {width: 100%;height: 100%;position: absolute;left: 0;top: 0;}
.sk-circle .sk-child:before {content: '';display: block;margin: 0 auto;width: 15%;height: 15%;background-color: #fff;border-radius: 100%;-webkit-animation: sk-circleBounceDelay 1.2s infinite ease-in-out both;animation: sk-circleBounceDelay 1.2s infinite ease-in-out both;}
.sk-circle .sk-circle2 {-webkit-transform: rotate(30deg);-ms-transform: rotate(30deg);transform: rotate(30deg); }
.sk-circle .sk-circle3 {-webkit-transform: rotate(60deg);-ms-transform: rotate(60deg);transform: rotate(60deg); }
.sk-circle .sk-circle4 {-webkit-transform: rotate(90deg); -ms-transform: rotate(90deg); transform: rotate(90deg); }
.sk-circle .sk-circle5 {-webkit-transform: rotate(120deg); -ms-transform: rotate(120deg); transform: rotate(120deg); }
.sk-circle .sk-circle6 {-webkit-transform: rotate(150deg); -ms-transform: rotate(150deg); transform: rotate(150deg); }
.sk-circle .sk-circle7 {-webkit-transform: rotate(180deg); -ms-transform: rotate(180deg); transform: rotate(180deg); }
.sk-circle .sk-circle8 {-webkit-transform: rotate(210deg); -ms-transform: rotate(210deg); transform: rotate(210deg); }
.sk-circle .sk-circle9 {-webkit-transform: rotate(240deg); -ms-transform: rotate(240deg); transform: rotate(240deg); }
.sk-circle .sk-circle10 {-webkit-transform: rotate(270deg); -ms-transform: rotate(270deg); transform: rotate(270deg); }
.sk-circle .sk-circle11 {-webkit-transform: rotate(300deg); -ms-transform: rotate(300deg); transform: rotate(300deg); }
.sk-circle .sk-circle12 {-webkit-transform: rotate(330deg); -ms-transform: rotate(330deg); transform: rotate(330deg); }
.sk-circle .sk-circle2:before {-webkit-animation-delay: -1.1s; animation-delay: -1.1s; }
.sk-circle .sk-circle3:before {-webkit-animation-delay: -1s; animation-delay: -1s; }
.sk-circle .sk-circle4:before {-webkit-animation-delay: -0.9s; animation-delay: -0.9s; }
.sk-circle .sk-circle5:before {-webkit-animation-delay: -0.8s; animation-delay: -0.8s; }
.sk-circle .sk-circle6:before {-webkit-animation-delay: -0.7s; animation-delay: -0.7s; }
.sk-circle .sk-circle7:before {-webkit-animation-delay: -0.6s; animation-delay: -0.6s; }
.sk-circle .sk-circle8:before {-webkit-animation-delay: -0.5s; animation-delay: -0.5s; }
.sk-circle .sk-circle9:before {-webkit-animation-delay: -0.4s; animation-delay: -0.4s; }
.sk-circle .sk-circle10:before {-webkit-animation-delay: -0.3s; animation-delay: -0.3s; }
.sk-circle .sk-circle11:before {-webkit-animation-delay: -0.2s; animation-delay: -0.2s; }
.sk-circle .sk-circle12:before {-webkit-animation-delay: -0.1s; animation-delay: -0.1s; }
@-webkit-keyframes sk-circleBounceDelay {0%, 80%, 100% {-webkit-transform: scale(0); transform: scale(0); } 40% {-webkit-transform: scale(1); transform: scale(1); } }
@keyframes sk-circleBounceDelay {0%, 80%, 100% {-webkit-transform: scale(0); transform: scale(0); } 40% {-webkit-transform: scale(1); transform: scale(1); } }
/*type2*/
.spinner {margin: 10px auto ;width: 40px;text-align: center;}
.spinner > div {width: 8px;height: 8px;background-color: #fff;border-radius: 100%;display: inline-block;-webkit-animation: sk-bouncedelay 1.4s infinite ease-in-out both;animation: sk-bouncedelay 1.4s infinite ease-in-out both;}
.spinner .bounce1 {-webkit-animation-delay: -0.32s;animation-delay: -0.32s;}
.spinner .bounce2 {-webkit-animation-delay: -0.16s;animation-delay: -0.16s;}
@-webkit-keyframes sk-bouncedelay {0%, 80%, 100% { -webkit-transform: scale(0) } 40% { -webkit-transform: scale(1.0) } }
@keyframes sk-bouncedelay {0%, 80%, 100% {-webkit-transform: scale(0); transform: scale(0); } 40% {-webkit-transform: scale(1.0); transform: scale(1.0); } }

type1


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 簡介 "transformjs" 在非react領域用得風生水起,那麼react技術棧的同學能用上嗎?答案是可以的。junexie童鞋已經造了個 "react版本" 。 動畫實現方式 傳統 web 動畫的兩種方式 : 1. 純粹的CSS3 :如:transition/animation+transf ...
  • 基本上每個項目都需要用到模態框組件,由於在最近的項目中,alert組件和confirm是兩套完全不一樣的設計,所以我將他們分成了兩個組件,本文主要討論的是confirm組件的實現。 ...
  • 一、AJAX示例 AJAX全稱為“Asynchronous JavaScript And XML”(非同步JavaScript和XML) 是指一種創建互動式網頁應用的開發技術、改善用戶體驗,實現無刷新效果。 1.1、優點 不需要插件支持 優秀的用戶體驗 提高Web程式的性能 減輕伺服器和帶寬的負擔 1 ...
  • 一、插入換行 ~:表示同輩元素之後指定類型的元素,如;elm1 ~ elm2表示,elm1之後的所有elm2元素,且elm1與elm2都是在同一個父級元素。 +:表示同輩元素的兄弟元素。 \A:一個空白換行符 解決方案: 在dd與dt相鄰的dt上的子元素前面加入一個空白換行符 在相鄰的dd與dd之間 ...
  • 環境:win7 64位 IE9 錯誤:SCRIPT5011:不能執行已釋放Script的代碼。 現象:在父窗體的close()中調用嵌套的iframe頁面的js方法返回一個對象時拋此異常。 原因:在一個iframe中定義對象,在這個iframe被刪除後,方法執行的環境丟失,就會報這個錯誤 我的解決辦 ...
  • 通過簡單的示例代碼,短暫地回顧了jQuery的Deferred使用後,我們一起來看看jQuery是怎麼實現Deferred,當然解讀jQuery源代碼的版本是大於1.8的。 ...
  • 本文記錄了我在項目中用過的一些JavaScript小功能,有需要的可以參考下;如有不足之處,還望眾位同行指正。 ...
  • 一、什麼是Vue? Vue.js(讀音 /vjuː/, 類似於 view) 是一套構建用戶界面的 漸進式框架。與其他重量級框架不同的是,Vue 採用自底向上增量開發的設計。Vue 的核心庫只關註視圖層,並且非常容易學習,非常容易與其它庫或已有項目整合。另一方面,Vue 完全有能力驅動採用單文件組件和 ...
一周排行
    -Advertisement-
    Play Games
  • 前言 本文介紹一款使用 C# 與 WPF 開發的音頻播放器,其界面簡潔大方,操作體驗流暢。該播放器支持多種音頻格式(如 MP4、WMA、OGG、FLAC 等),並具備標記、實時歌詞顯示等功能。 另外,還支持換膚及多語言(中英文)切換。核心音頻處理採用 FFmpeg 組件,獲得了廣泛認可,目前 Git ...
  • OAuth2.0授權驗證-gitee授權碼模式 本文主要介紹如何筆者自己是如何使用gitee提供的OAuth2.0協議完成授權驗證並登錄到自己的系統,完整模式如圖 1、創建應用 打開gitee個人中心->第三方應用->創建應用 創建應用後在我的應用界面,查看已創建應用的Client ID和Clien ...
  • 解決了這個問題:《winForm下,fastReport.net 從.net framework 升級到.net5遇到的錯誤“Operation is not supported on this platform.”》 本文內容轉載自:https://www.fcnsoft.com/Home/Sho ...
  • 國內文章 WPF 從裸 Win 32 的 WM_Pointer 消息獲取觸摸點繪製筆跡 https://www.cnblogs.com/lindexi/p/18390983 本文將告訴大家如何在 WPF 裡面,接收裸 Win 32 的 WM_Pointer 消息,從消息裡面獲取觸摸點信息,使用觸摸點 ...
  • 前言 給大家推薦一個專為新零售快消行業打造了一套高效的進銷存管理系統。 系統不僅具備強大的庫存管理功能,還集成了高性能的輕量級 POS 解決方案,確保頁面載入速度極快,提供良好的用戶體驗。 項目介紹 Dorisoy.POS 是一款基於 .NET 7 和 Angular 4 開發的新零售快消進銷存管理 ...
  • ABP CLI常用的代碼分享 一、確保環境配置正確 安裝.NET CLI: ABP CLI是基於.NET Core或.NET 5/6/7等更高版本構建的,因此首先需要在你的開發環境中安裝.NET CLI。這可以通過訪問Microsoft官網下載並安裝相應版本的.NET SDK來實現。 安裝ABP ...
  • 問題 問題是這樣的:第三方的webapi,需要先調用登陸介面獲取Cookie,訪問其它介面時攜帶Cookie信息。 但使用HttpClient類調用登陸介面,返回的Headers中沒有找到Cookie信息。 分析 首先,使用Postman測試該登陸介面,正常返回Cookie信息,說明是HttpCli ...
  • 國內文章 關於.NET在中國為什麼工資低的分析 https://www.cnblogs.com/thinkingmore/p/18406244 .NET在中國開發者的薪資偏低,主要因市場需求、技術棧選擇和企業文化等因素所致。歷史上,.NET曾因微軟的閉源策略發展受限,儘管後來推出了跨平臺的.NET ...
  • 在WPF開發應用中,動畫不僅可以引起用戶的註意與興趣,而且還使軟體更加便於使用。前面幾篇文章講解了畫筆(Brush),形狀(Shape),幾何圖形(Geometry),變換(Transform)等相關內容,今天繼續講解動畫相關內容和知識點,僅供學習分享使用,如有不足之處,還請指正。 ...
  • 什麼是委托? 委托可以說是把一個方法代入另一個方法執行,相當於指向函數的指針;事件就相當於保存委托的數組; 1.實例化委托的方式: 方式1:通過new創建實例: public delegate void ShowDelegate(); 或者 public delegate string ShowDe ...