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 相关文章推荐
全面总结使用CSS实现水平垂直居中效果的方法
Mar 10 HTML / CSS
关于CSS Tooltips(鼠标经过时显示)的效果
Apr 10 HTML / CSS
css3弹性盒模型(Flexbox)详细介绍
Oct 08 HTML / CSS
使用CSS Grid布局实现网格的流动
Dec 30 HTML / CSS
css sprite简单实例
May 23 HTML / CSS
CSS的background属性及CSS3的背景图片设置总结
Jun 13 HTML / CSS
HTML5 Canvas API中drawImage()方法的使用实例
Mar 25 HTML / CSS
HTML5实现的震撼3D焦点图动画的示例代码
Sep 26 HTML / CSS
HTML5中实现拖放效果无须借助javascript
Dec 26 HTML / CSS
HTML5中判断横屏竖屏的方法(移动端)
Aug 04 HTML / CSS
用CSS3画一个爱心
Apr 27 HTML / CSS
浅谈由position属性引申的css进阶讨论
May 25 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
PHP自定义函数收代码
2010/08/01 PHP
yii2高级应用之自定义组件实现全局使用图片上传功能的方法
2016/10/08 PHP
Yii2实现自定义独立验证器的方法
2017/05/05 PHP
PHP中类与对象功能、用法实例解读
2020/03/27 PHP
Laravel框架数据库迁移操作实例详解
2020/04/06 PHP
firefox和IE系列的相关区别整理 以备后用
2009/12/28 Javascript
JavaScript中逗号运算符介绍及使用示例
2015/03/13 Javascript
如何使用HTML5地理位置定位功能
2015/04/27 Javascript
javascript实现的字符串与十六进制表示字符串相互转换方法
2015/07/17 Javascript
web前端开发JQuery常用实例代码片段(50个)
2015/08/28 Javascript
jQuery超简单选项卡完整实例
2015/09/26 Javascript
原生javascript实现图片无缝滚动效果
2016/02/12 Javascript
javascript类型系统_正则表达式RegExp类型详解
2016/06/24 Javascript
javascript实现根据汉字获取简拼
2016/09/25 Javascript
使用vue.js实现checkbox的全选和多个的删除功能
2017/02/17 Javascript
jQuery+ThinkPHP+Ajax实现即时消息提醒功能实例代码
2017/03/21 jQuery
利用js实现前后台传送Json的示例代码
2018/03/29 Javascript
ElementUI Tag组件实现多标签生成的方法示例
2019/07/08 Javascript
JS计算斐波拉切代码实例
2019/09/12 Javascript
js实现图片实时时钟
2020/01/15 Javascript
[02:06]DOTA2肉山黑名单魔法终结者 敌法师中文配音鉴赏
2013/06/17 DOTA
TensorFlow实现创建分类器
2018/02/06 Python
Python爬虫框架Scrapy实例代码
2018/03/04 Python
浅谈pandas筛选出表中满足另一个表所有条件的数据方法
2019/02/08 Python
django的model操作汇整详解
2019/07/26 Python
用python生成与调用cntk模型代码演示方法
2019/08/26 Python
Python实现图片查找轮廓、多边形拟合、最小外接矩形代码
2020/07/14 Python
python dir函数快速掌握用法技巧
2020/12/09 Python
python 高阶函数简单介绍
2021/02/19 Python
比利时买床:Beter Bed
2017/12/06 全球购物
什么叫做SQL注入,如何防止
2016/10/04 面试题
招商业务员岗位职责
2013/12/16 职场文书
打架检讨书400字
2014/01/17 职场文书
入党自我评价优缺点
2014/01/25 职场文书
导师工作推荐信范文
2014/05/17 职场文书
python区块链持久化和命令行接口实现简版
2022/05/25 Python