项目中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:;}
.tiploading .tiploading-con{position:absolute;bottom:10px;left:;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:;top:;}
.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

css3加载ing动画的更多相关文章

  1. 纯css3 加载loading动画特效

    最近项目中要实现当页面还没有加载完给用户提示正在加载的loading,本来是想做个图片提示的,但是图片如果放大电脑的分辨率就会感觉到很虚,体验效果很不好.于是就采用css3+js实现这个loading ...

  2. 兼容ie10及以上css3加载进度动画

      html <div class="spinner">   <div class="rect1"></div>   < ...

  3. 纯css3加载动画

    <!DOCTYPE html><html> <head> <meta charset="utf-8"> <meta name= ...

  4. CSS3实现加载数据动画2

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  5. CSS3实现加载数据动画1

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  6. 页面预加载loading动画,再载入内容

    默认情况下如果网站请求速度慢,所以会有一段时间的空白页面等等,用户体验效果不好,见到很多的页面都有预加载的效果,加载之前先加载一个动画,后台进程继续加载页面内容,当页面内容加载完之后再退出动画显示内容 ...

  7. HTML5+javascript实现图片加载进度动画效果

    在网上找资料的时候,看到网上有图片加载进度的效果,手痒就自己也写了一个. 图片加载完后,隐藏loading效果. 想看加载效果,请ctrel+F5强制刷新或者清理缓存. 效果预览:   0%   // ...

  8. Android 自定义View修炼-自定义加载进度动画XCLoadingImageView

    一.概述 本自定义View,是加载进度动画的自定义View,继承于ImageView来实现,主要实现蒙层加载进度的加载进度效果. 支持水平左右加载和垂直上下加载四个方向,同时也支持自定义蒙层进度颜色. ...

  9. CSharpGL(50)使用Assimp加载骨骼动画

    CSharpGL(50)使用Assimp加载骨骼动画 在(http://ogldev.atspace.co.uk/www/tutorial38/tutorial38.html)介绍了C++用Asism ...

随机推荐

  1. CSS滚动条

    × 目录 [1]条件 [2]默认 [3]尺寸[4]兼容[5]自定义 前面的话 滚动条在网页中经常见到,却并没有受到足够的重视.只有当因为滚动条的问题需要处理兼容性时,才进行调试操作.本文将就滚动条的常 ...

  2. ES6入门系列四(测试题分析)

    0.导言 ES6中新增了不少的新特性,来点测试题热热身.具体题目来源请看:http://perfectionkills.com/javascript-quiz-es6/. 以下将一题一题来解析what ...

  3. 使用Google产品以来遇到的最糟糕、最霸道、最让人抓狂的设计

    很久没有登录cnblogs@gmail.com这个邮箱,今天通过gmail.com登录了一下,登录后出现一个对话框要求设置性别与出生日期,而且必须要设置,不设置不让登录. 这个邮箱是我们网站用的是邮箱 ...

  4. Testing - 测试基础 - 概念

    测试是为了度量和提高被测试软件的质量,对测试软件进行工程设计.实施.维护的的整个生命周期过程. 仅仅发现Bug是测试的初步,而分析出根本原因推动问题的解决,却要有很深的功底. 不同的测试岗位从事不同的 ...

  5. Android反编译(三)之重签名

    Android反编译(三) 之重签名 [目录] 1.原理 2.工具与准备工作 3.操作步骤 4.装X技巧 5.问题 1.原理 1).APK签名的要点 a.所有的应用程序都必须有数字证书 ,Androi ...

  6. installshield生成时提示6003错误的一种可能

    因为项目需要,2014年写过的一个老项目需要重新打包.开发电脑换了,原来开发的系统是win7,现在已经升到了win10.而且原来使用installshield limited 2013开发的打包项目已 ...

  7. Electro桌面应用开发之HelloWorld

    简介 Electron (http://http://electron.atom.io‎)提供了一个使用Node.js进行桌面应用开发的环境. 本文介绍了一个基于Electron的HelloWorld ...

  8. 基于HTML5技术的电力3D监控应用(二)

    上篇介绍了我们电力项目的基本情况,我们选用HTML5技术还是顶着很大压力,毕竟HTML5技术性能行不行,浏览器兼容性会不会有问题,这些在项目选型阶段还是充满疑惑,项目做到现在终于快收尾了我们才敢松口气 ...

  9. MVC中Action的执行过程

    接着上一篇:MVC控制器的激活过程 一.代码现行,该伪代码大致解析了Action的执行的过程 try { Run each IAuthorizationFilter's OnAuthorization ...

  10. 单例模式ARC和非ARC

    ARC环境下的单例模式: static id _instance = nil; + (id)allocWithZone:(struct _NSZone *)zone { if (_instance = ...