项目中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

本文转载自:http://www.cnblogs.com/wmlucky/p/6195851.html

转载于:https://www.cnblogs.com/Eton/p/6200616.html

css3加载ing动画相关推荐

  1. css3加载中动画效果,CSS3实现加载中的动画效果

    Loading 的菊花图形组合的不太好,基本上实现这个功能了 动画解析 这个动画用到的 CSS3 特性: transform 主要使用 transform 属性的 rotate,将线条组合成 Load ...

  2. html页面加载动画尺寸,6种CSS3加载动画

    插件描述:6种CSS3炫酷预加载Loading,非常酷的纯CSS3炫酷预加载Loading指示器动画特效.这组loading指示器共6种效果,都是使用:before和:after伪元素,以及CSS帧动 ...

  3. HTML小案例-使用CSS3实现网页加载loding动画

    HTML小案例-使用CSS3实现网页加载loding动画 话不多说先看效果 ** 以下为源代码 ** <!DOCTYPE html> <html lang="zh-CN&q ...

  4. jsp预加载转圈_30种CSS3炫酷页面预加载loading动画特效(推荐)

    这是一组效果非常炫酷的CSS3页面预加载loading动画特效.该特效共有30种不同的loading效果.所有的加载动画都是使用CSS3来完成,jQuery代码只是用于隐藏加载动画.当你点击页面的任何 ...

  5. CSS3实现loading(加载)动画效果

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

  6. html间隔代码_HTML+CSS基础入门开发,经典Loading加载缩放动画特效

    大家好,本篇文章分享经典Loading加载缩放动画特效,欢迎参考和指正. 效果图: Loading加载缩放动画特效 HTML代码: CSS代码: 知识点: animation:是CSS3的动画属性,这 ...

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

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

  8. css3加载中loading代码js特效大全

    下载地址 css3加载中loading代码特效大全,非常多的预加载动画特效代码. dd:

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

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

最新文章

  1. 智源研究院发布 2020 年世界十大 AI 进展
  2. 冒泡排序和鸡尾酒排序(改进的冒泡排序)
  3. 性能测试(05)-表达式和业务关联-json关联
  4. java 1.5.0 gcj_CentOS安装JAVA后JAVA版本不对的问题
  5. 计算机应用基础专科作业二,电子科大18秋《计算机应用基础(专科)》在线作业2...
  6. vuforia for unity 注意事项
  7. linux下常用的dns软件,Linux常见应用--DNS服务器常见应用实现
  8. 简历推荐_5位AI产品经理
  9. 【运营数据分析】运营数据分析怎么做?建立运营数据分析思维
  10. MATLAB | 分形的艺术——(Mandelbrot)曼德勃罗特集合
  11. vue列表左右箭头滑动_vue点击左右箭头改变数据
  12. c语言对文本霍夫曼编码,C语言之霍夫曼编码学习
  13. 使用文氏图说明贝叶斯公式如何导出、推导朴素贝叶斯算法以及实例
  14. [音乐] 逆转裁判第二季 OP『Nеvеr Losе』
  15. python魔法方法指南_2011年最热门的20种方法指南
  16. 个人家用nas_方便易用的家用NAS私家云不超千元
  17. Excel给证件照换底色,红、蓝、白底任你换,看完涨知识了
  18. 常见网页悬浮广告(JavaScript)
  19. python是什么语言开发的,python编程语言的特点
  20. Job And Schedule (V8R6C3)

热门文章

  1. ubuntu连接有线局域网后无法使用无线网卡上网
  2. flink的web ui中五颜六色的方块是什么意思?
  3. django的admin管理后台到底是否靠谱呢
  4. 基于Pyspark和Thunder的神经图像数据分析-实验运行结果
  5. Spark-shell进行粘贴模式
  6. ubuntu16.04修改xfce下的gedit的背景颜色
  7. ubuntu16.04登录mysql出现1045的报错或者2002报错
  8. SQLServer中round函数
  9. tornado框架的get方法传递参数
  10. MySQL源码学习——DBUG调试