CSS3实现10种Loading效果


Posted in HTML / CSS onJuly 11, 2016

用CSS3实现了几种常见的Loading效果,虽然很简单,但还是分享一下,顺便也当是做做笔记……

第1种效果:

CSS3实现10种Loading效果

代码如下:

XML/HTML Code复制内容到剪贴板
  1. <div class="loading">  
  2.         <span></span>  
  3.         <span></span>  
  4.         <span></span>  
  5.         <span></span>  
  6.         <span></span>  
  7. </div>  
CSS Code复制内容到剪贴板
  1. .loading{   
  2.             width80px;   
  3.             height40px;   
  4.             margin: 0 auto;   
  5.             margin-top:100px;   
  6.         }   
  7.         .loading span{   
  8.             displayinline-block;   
  9.             width8px;   
  10.             height: 100%;   
  11.             border-radius: 4px;   
  12.             background: lightgreen;   
  13.             -webkit-animation: load 1s ease infinite;   
  14.         }   
  15.         @-webkit-keyframes load{   
  16.             0%,100%{   
  17.                 height40px;   
  18.                 background: lightgreen;   
  19.             }   
  20.             50%{   
  21.                 height70px;   
  22.                 margin: -15px 0;   
  23.                 background: lightblue;   
  24.             }   
  25.         }   
  26.         .loading span:nth-child(2){   
  27.             -webkit-animation-delay:0.2s;   
  28.         }   
  29.         .loading span:nth-child(3){   
  30.             -webkit-animation-delay:0.4s;   
  31.         }   
  32.         .loading span:nth-child(4){   
  33.             -webkit-animation-delay:0.6s;   
  34.         }   
  35.         .loading span:nth-child(5){   
  36.             -webkit-animation-delay:0.8s;   
  37.         }   
  38.   

第2种效果:

CSS3实现10种Loading效果

代码如下:

XML/HTML Code复制内容到剪贴板
  1. <div class="loading">  
  2.         <span></span>  
  3. </div>  
  4.   
CSS Code复制内容到剪贴板
  1. .loading{   
  2.             width150px;   
  3.             height4px;   
  4.             border-radius: 2px;   
  5.             margin: 0 auto;   
  6.             margin-top:100px;   
  7.             positionrelative;   
  8.             background: lightgreen;   
  9.             -webkit-animation: changeBgColor 1.04s ease-in infinite alternate;   
  10.         }   
  11.         .loading span{   
  12.             displayinline-block;   
  13.             width16px;   
  14.             height16px;   
  15.             border-radius: 50%;   
  16.             background: lightgreen;   
  17.             positionabsolute;   
  18.             margin-top: -7px;   
  19.             margin-left:-8px;   
  20.             -webkit-animation: changePosition 1.04s ease-in infinite alternate;   
  21.         }   
  22.         @-webkit-keyframes changeBgColor{   
  23.             0%{   
  24.                 background: lightgreen;   
  25.             }   
  26.             100%{   
  27.                 background: lightblue;   
  28.             }   
  29.         }   
  30.         @-webkit-keyframes changePosition{   
  31.             0%{   
  32.                 background: lightgreen;   
  33.             }   
  34.             100%{   
  35.                 margin-left142px;   
  36.                 background: lightblue;   
  37.             }   
  38.         }   
  39.   

第3-5种效果:

CSS3实现10种Loading效果

CSS3实现10种Loading效果

CSS3实现10种Loading效果

代码如下:

XML/HTML Code复制内容到剪贴板
  1. <div class="loading">  
  2.         <span></span>  
  3.         <span></span>  
  4.         <span></span>  
  5.         <span></span>  
  6.         <span></span>  
  7. </div>   

第3-5种效果的css样式分别为:

CSS Code复制内容到剪贴板
  1. .loading{   
  2.             width150px;   
  3.             height15px;   
  4.             margin: 0 auto;   
  5.             positionrelative;   
  6.             margin-top:100px;   
  7.         }   
  8.         .loading span{   
  9.             positionabsolute;   
  10.             width15px;   
  11.             height: 100%;   
  12.             border-radius: 50%;   
  13.             background: lightgreen;   
  14.             -webkit-animation: load 1.04s ease-in infinite alternate;   
  15.         }   
  16.         @-webkit-keyframes load{   
  17.             0%{   
  18.                 opacity: 1;   
  19.                 -webkit-transform: translate(0px);   
  20.             }   
  21.             100%{   
  22.                 opacity: 0.2;   
  23.                 -webkit-transform: translate(150px);   
  24.             }   
  25.         }   
  26.         .loading span:nth-child(1){   
  27.             -webkit-animation-delay:0.13s;   
  28.         }   
  29.         .loading span:nth-child(2){   
  30.             -webkit-animation-delay:0.26s;   
  31.         }   
  32.         .loading span:nth-child(3){   
  33.             -webkit-animation-delay:0.39s;   
  34.         }   
  35.         .loading span:nth-child(4){   
  36.             -webkit-animation-delay:0.52s;   
  37.         }   
  38.         .loading span:nth-child(5){   
  39.             -webkit-animation-delay:0.65s;   
  40.         }  

第6-8种效果:

CSS3实现10种Loading效果

CSS3实现10种Loading效果

CSS3实现10种Loading效果

代码如下:

XML/HTML Code复制内容到剪贴板
  1. <div class="loading">  
  2.         <span></span>  
  3.         <span></span>  
  4.         <span></span>  
  5.         <span></span>  
  6.         <span></span>  
  7. </div>  

第6-8种效果的css样式分别为:

CSS Code复制内容到剪贴板
  1. .loading{   
  2.             width150px;   
  3.             height15px;   
  4.             margin: 0 auto;   
  5.             margin-top:100px;   
  6.             text-aligncenter;   
  7.         }   
  8.         .loading span{   
  9.             displayinline-block;   
  10.             width15px;   
  11.             height: 100%;   
  12.             margin-right5px;   
  13.             background: lightgreen;   
  14.             -webkit-animation: load 1.04s ease infinite;   
  15.         }   
  16.         .loading span:last-child{   
  17.             margin-right0px;    
  18.         }   
  19.         @-webkit-keyframes load{   
  20.             0%{   
  21.                 opacity: 1;   
  22.             }   
  23.             100%{   
  24.                 opacity: 0;   
  25.             }   
  26.         }   
  27.         .loading span:nth-child(1){   
  28.             -webkit-animation-delay:0.13s;   
  29.         }   
  30.         .loading span:nth-child(2){   
  31.             -webkit-animation-delay:0.26s;   
  32.         }   
  33.         .loading span:nth-child(3){   
  34.             -webkit-animation-delay:0.39s;   
  35.         }   
  36.         .loading span:nth-child(4){   
  37.             -webkit-animation-delay:0.52s;   
  38.         }   
  39.         .loading span:nth-child(5){   
  40.             -webkit-animation-delay:0.65s;   
  41.         }  

第9-10种效果:

CSS3实现10种Loading效果

CSS3实现10种Loading效果

代码如下:

XML/HTML Code复制内容到剪贴板
  1. <div class="loadEffect">  
  2.         <span></span>  
  3.         <span></span>  
  4.         <span></span>  
  5.         <span></span>  
  6.         <span></span>  
  7.         <span></span>  
  8.         <span></span>  
  9.         <span></span>  
  10. </div>  

CSS样式分别为:

CSS Code复制内容到剪贴板
  1. .loadEffect{   
  2.             width100px;   
  3.             height100px;   
  4.             positionrelative;   
  5.             margin: 0 auto;   
  6.             margin-top:100px;   
  7.         }   
  8.         .loadEffect span{   
  9.             displayinline-block;   
  10.             width16px;   
  11.             height16px;   
  12.             border-radius: 50%;   
  13.             background: lightgreen;   
  14.             positionabsolute;   
  15.             -webkit-animation: load 1.04s ease infinite;   
  16.         }   
  17.         @-webkit-keyframes load{   
  18.             0%{   
  19.                 opacity: 1;   
  20.             }   
  21.             100%{   
  22.                 opacity: 0.2;   
  23.             }   
  24.         }   
  25.         .loadEffect span:nth-child(1){   
  26.             left: 0;   
  27.             top: 50%;   
  28.             margin-top:-8px;   
  29.             -webkit-animation-delay:0.13s;   
  30.         }   
  31.         .loadEffect span:nth-child(2){   
  32.             left14px;   
  33.             top14px;   
  34.             -webkit-animation-delay:0.26s;   
  35.         }   
  36.         .loadEffect span:nth-child(3){   
  37.             left: 50%;   
  38.             top: 0;   
  39.             margin-left: -8px;   
  40.             -webkit-animation-delay:0.39s;   
  41.         }   
  42.         .loadEffect span:nth-child(4){   
  43.             top14px;   
  44.             rightright:14px;   
  45.             -webkit-animation-delay:0.52s;   
  46.         }   
  47.         .loadEffect span:nth-child(5){   
  48.             rightright: 0;   
  49.             top: 50%;   
  50.             margin-top:-8px;   
  51.             -webkit-animation-delay:0.65s;   
  52.         }   
  53.         .loadEffect span:nth-child(6){   
  54.             rightright14px;   
  55.             bottombottom:14px;   
  56.             -webkit-animation-delay:0.78s;   
  57.         }   
  58.         .loadEffect span:nth-child(7){   
  59.             bottombottom: 0;   
  60.             left: 50%;   
  61.             margin-left: -8px;   
  62.             -webkit-animation-delay:0.91s;   
  63.         }   
  64.         .loadEffect span:nth-child(8){   
  65.             bottombottom14px;   
  66.             left14px;   
  67.             -webkit-animation-delay:1.04s;   
  68.         }  

PS:CSS样式代码其实很多重复,主要就是动画不一样,但为了方便以后直接拿来用,就先不整理了。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持三水点靠木。

本文链接:http://www.cnblogs.com/jr1993/p/4622039.html

HTML / CSS 相关文章推荐
利用CSS3实现动态的二级三级菜单效果实例源码
Jan 04 HTML / CSS
纯CSS打造(无图像无js)的非常流行的讲话(语音)气泡效果
Dec 28 HTML / CSS
CSS3 制作旋转的大风车(充满童年回忆)
Jan 30 HTML / CSS
css3利用transform变形结合事件完成扇形导航
Oct 26 HTML / CSS
HTML5中通过li-canvas轻松实现单图、多图、圆角图绘制,单行文字、多行文字等
Nov 30 HTML / CSS
html通过canvas转成base64的方法
Jul 18 HTML / CSS
使用html5 canvas创建太空游戏的示例
May 08 HTML / CSS
浅谈利用缓存来优化HTML5 Canvas程序的性能
May 12 HTML / CSS
HTML5不支持标签和新增标签详解
Jun 27 HTML / CSS
详解px单位html5响应式方案
Mar 08 HTML / CSS
原生 JS+CSS+HTML 实现时序图的方法
Jul 31 HTML / CSS
html5 外链式实现加减乘除的代码
Sep 04 HTML / CSS
CSS3实现可爱的小黄人动画
Jul 11 #HTML / CSS
使用CSS3滤镜的filter:blur属性制作毛玻璃模糊效果的方法
Jul 08 #HTML / CSS
分享CSS3制作卡片式图片的方法
Jul 08 #HTML / CSS
CSS3制作缩略图的详细过程
Jul 08 #HTML / CSS
CSS3制作圆角图片和椭圆形图片
Jul 08 #HTML / CSS
css3media响应式布局实例
Jul 08 #HTML / CSS
使用CSS3的ruby-position固定注音位置的用法示例
Jul 05 #HTML / CSS
You might like
dedecms模版制作使用方法
2007/04/03 PHP
centos 7.2下搭建LNMP环境教程
2016/11/20 PHP
对textarea框的代码调试,而且功能上使用非常方便,酷
2006/06/30 Javascript
mouse_on_title.js
2006/08/25 Javascript
JS写的数字拼图小游戏代码[学习参考]
2008/10/29 Javascript
jQuery 白痴级入门教程
2009/11/11 Javascript
jquery 页面全选框实践代码
2010/04/02 Javascript
JavaScript优化以及前段开发小技巧
2017/02/02 Javascript
从零学习node.js之mysql数据库的操作(五)
2017/02/24 Javascript
基于vue2.0+vuex的日期选择组件功能实现
2017/03/13 Javascript
详解vue.js+UEditor集成 [前后端分离项目]
2017/07/07 Javascript
浅谈JavaScript的innerWidth与innerHeight
2017/10/12 Javascript
node.js的exports、module.exports与ES6的export、export default深入详解
2017/10/26 Javascript
js构造函数创建对象是否加new问题
2018/01/22 Javascript
vue中Axios的封装与API接口的管理详解
2018/08/09 Javascript
微信小程序中显示倒计时代码实例
2019/05/09 Javascript
浅谈layui 表单元素的选中问题
2019/10/25 Javascript
深入浅析golang zap 日志库使用(含文件切割、分级别存储和全局使用等)
2020/02/19 Javascript
Python中使用hashlib模块处理算法的教程
2015/04/28 Python
Python新手入门最容易犯的错误总结
2017/04/24 Python
Python中str.join()简单用法示例
2018/03/20 Python
用python处理图片之打开\显示\保存图像的方法
2018/05/04 Python
如何通过Python实现标签云算法
2019/07/02 Python
python3 中时间戳、时间、日期的转换和加减操作
2020/07/14 Python
哪种Python框架适合你?简单介绍几种主流Python框架
2020/08/04 Python
基于PyInstaller各参数的含义说明
2021/03/04 Python
基层干部2014全国两会学习心得体会
2014/03/10 职场文书
新法人代表任命书
2014/06/06 职场文书
纪念九一八事变演讲稿:忘记意味着背叛
2014/09/14 职场文书
2015欢度元旦标语口号
2014/12/09 职场文书
2019旅游导游工作总结
2019/06/27 职场文书
解决thinkphp6(tp6)在状态码500下不报错,或者显示错误“Malformed UTF-8 characters”的问题
2021/04/01 PHP
如何使用分区处理MySQL的亿级数据优化
2021/06/18 MySQL
MySQL基于索引的压力测试的实现
2021/11/07 MySQL
Java如何实现通过键盘输入一个数组
2022/02/15 Java/Android
Java中的Kafka为什么性能这么快及4大核心详析
2022/09/23 Java/Android