实现如图所示的点点点loading效果:

一:CSS3 animation实现代码

html代码:

提交订单中<span class="ani_dot">...</span>

css代码:

.ani_dot {font-family: simsun;
}
:root .ani_dot { /* 这里使用Hack是因为IE6~IE8浏览器下, vertical-align解析不规范,值为bottom或其他会改变按钮的实际高度*/display: inline-block;width: 1.5em;vertical-align: bottom;overflow: hidden;
}
@-webkit-keyframes dot {0% { width: 0; margin-right: 1.5em; }33% { width: .5em; margin-right: 1em; }66% { width: 1em; margin-right: .5em; }100% { width: 1.5em; margin-right: 0;}
}
.ani_dot {-webkit-animation: dot 3s infinite step-start;
}@keyframes dot {0% { width: 0; margin-right: 1.5em; }33% { width: .5em; margin-right: 1em; }66% { width: 1em; margin-right: .5em; }100% { width: 1.5em; margin-right: 0;}
}
.ani_dot {animation: dot 3s infinite step-start;
}

出现的就是如图所示的结果。
注意点:

1.IE10+以及其他浏览器,点点点动画消失,IE6-IE9是普通的点点点文字。
2.animate动画是连续的,但是我们这儿是一帧一帧的,一卡一卡的,不是那么连续的效果,用到step-start
3.上面代码还用到了css3的选择器:root。:root为IE9+以及其他现代浏览器Hack, IE6-7甚至IE8下,inline-block水平元素的vertical-align:bottom解析与inline水平是有差异的,会导致高度撑开,因此,display: inline-block要hack处理。

二:动画(animation)的参数详解

由于上面用到了animation动画,这里详细介绍下这个animation的参数。

简介

CSS动画(Animations)简单说就是在一段固定的动画时间内暗中在某一频率内改变其CSS某个或某些值,从而达到视觉上的转换动画效果。Animations的很多方面都是可以控制的,包括动画运行时间,开始值和结束值,还有动画的暂停和延迟其开始时间等。

语法

<single-animation> = <single-animation-name> || <time> || <single-animation-timing-function> || <time> || <single-animation-iteration-count> || <single-animation-direction> || <single-animation-fill-mode> || <single-animation-play-state>

<' animation-name '>:检索或设置对象所应用的动画名称
<' animation-duration '>:检索或设置对象动画的持续时间
<' animation-timing-function '>:检索或设置对象动画的过渡类型
<' animation-delay '>:检索或设置对象动画延迟的时间
<' animation-iteration-count '>:检索或设置对象动画的循环次数
<' animation-direction '>:检索或设置对象动画在循环中是否反向运动
<' animation-fill-mode '>:检索或设置对象动画时间之外的状态
<' animation-play-state '>:检索或设置对象动画的状态。w3c正考虑是否将该属性移除,因为动画的状态可以通过其它的方式实现,比如重设样式

animation

所有动画属性的简写属性,除了 animation-play-state 属性。

animation-name

规定 @keyframes 动画的名称。就是@keyframes后面跟着的动画名称,本demo本文中名为dot,意思为“点”。

animation-duration

规定动画完成一个周期所花费的秒或毫秒。默认是 0。

animation-timing-function

规定动画的速度曲线。默认是 "ease"。

常见的动画速度参数:

  1. linear:线性过渡。等同于贝塞尔曲线(0.0, 0.0, 1.0, 1.0)
  2. ease:平滑过渡。等同于贝塞尔曲线(0.25, 0.1, 0.25, 1.0)
  3. ease-in:由慢到快。等同于贝塞尔曲线(0.42, 0, 1.0, 1.0)
  4. ease-out:由快到慢。等同于贝塞尔曲线(0, 0, 0.58, 1.0)
  5. ease-in-out:由慢到快再到慢。等同于贝塞尔曲线(0.42, 0, 0.58, 1.0)
  6. step-start:等同于 steps(1, start)
  7. step-end:等同于 steps(1, end)
  8. steps(<integer>[, [ start | end ]
    ]?):接受两个参数的步进函数。第一个参数必须为正整数,指定函数的步数。第二个参数取值可以是start或end,指定每一步的值发生变化的时间点。第二个参数是可选的,默认值为end。
  9. cubic-bezier(<number>, <number>, <number>,
    <number>):特定的贝塞尔曲线类型,4个数值需在[0, 1]区间内

animation-delay

规定动画何时开始。默认是 0。也即是指动画延时执行时间。

animation-iteration-count

规定动画被播放的次数。默认是 1。当然,我们可以设置2次,3次,依次递推。还有个无线循环关键字infinite,也即是反复循环播放动画。

animation-direction

规定动画是否在下一周期逆向地播放。默认是 "normal"。当然还有下列值:

  1. reverse:反方向运行
  2. alternate:动画先正常运行再反方向运行,并持续交替运行
  3. alternate-reverse:动画先反运行再正方向运行,并持续交替运行

animation-fill-mode

规定对象动画时间之外的状态。

  1. none:默认值。不设置对象动画之外的状态
  2. forwards:设置对象状态为动画结束时的状态
  3. backwards:设置对象状态为动画开始时的状态
  4. both:设置对象状态为动画结束或开始的状态,动画开始之前是"from"或"0%"关键帧;动画完成之后是"to"或"100%"关键帧状态。

animation-play-state

规定动画是否正在运行或暂停。默认是 "running"。还有个值paused:暂停。

三:animation动画实例

实例一使用from to

div{width:100px;height:100px;background:red;position:relative;animation:mymove 5s infinite;-moz-animation:mymove 5s infinite; /*Firefox*/-webkit-animation:mymove 5s infinite; /*Safari and Chrome*/
}
@keyframes mymove{from {left:0px;}to {left:200px;}
}
@-moz-keyframes mymove { /*Firefox*/from {left:0px;}to {left:200px;}
}
@-webkit-keyframes mymove{ /*Safari and Chrome*/from {left:0px;}to {left:200px;}
}

实例二使用百分比:

@keyframes myfirst{0%   {background: red; left:0px; top:0px;}25%  {background: yellow; left:200px; top:0px;}50%  {background: blue; left:200px; top:200px;}75%  {background: green; left:0px; top:200px;}100% {background: red; left:0px; top:0px;}
}@-moz-keyframes myfirst{ /* Firefox */0%   {background: red; left:0px; top:0px;}25%  {background: yellow; left:200px; top:0px;}50%  {background: blue; left:200px; top:200px;}75%  {background: green; left:0px; top:200px;}100% {background: red; left:0px; top:0px;}
}@-webkit-keyframes myfirst{ /* Safari 和 Chrome */0%   {background: red; left:0px; top:0px;}25%  {background: yellow; left:200px; top:0px;}50%  {background: blue; left:200px; top:200px;}75%  {background: green; left:0px; top:200px;}100% {background: red; left:0px; top:0px;}
}@-o-keyframes myfirst {/* Opera */0%   {background: red; left:0px; top:0px;}25%  {background: yellow; left:200px; top:0px;}50%  {background: blue; left:200px; top:200px;}75%  {background: green; left:0px; top:200px;}100% {background: red; left:0px; top:0px;}
}

实例三,利用js+Transform和Animation实现3D动画

示例地址:https://webkit.org/blog-files...
只有webkit内核的浏览器才能看到相关3D动画效果。
实现效果如图所示:

css代码:

body {font-family: 'Lucida Grande', Verdana, Arial;font-size: 12px;}#stage {margin: 150px auto;width: 600px;height: 400px;-webkit-perspective: 800;}#rotate {margin: 0 auto;width: 600px;height: 400px;-webkit-transform-style: preserve-3d;-webkit-animation-name: x-spin;-webkit-animation-duration: 7s;-webkit-animation-iteration-count: infinite;-webkit-animation-timing-function: linear;}.ring {margin: 0 auto;height: 110px;width: 600px;-webkit-transform-style: preserve-3d;-webkit-animation-iteration-count: infinite;-webkit-animation-timing-function: linear;}.ring > :nth-child(odd) {background-color: #995C7F;}.ring > :nth-child(even) {background-color: #835A99;}.poster {position: absolute;left: 250px;width: 100px;height: 100px;opacity: 0.7;color: rgba(0,0,0,0.9);-webkit-border-radius: 10px;}.poster > p {font-family: 'Georgia', serif;font-size: 36px;font-weight: bold;text-align: center;margin-top: 28px;}#ring-1 {-webkit-animation-name: y-spin;-webkit-animation-duration: 5s;}#ring-2 {-webkit-animation-name: back-y-spin;-webkit-animation-duration: 4s;}#ring-3 {-webkit-animation-name: y-spin;-webkit-animation-duration: 3s;}@-webkit-keyframes x-spin {0%    { -webkit-transform: rotateX(0deg); }50%   { -webkit-transform: rotateX(180deg); }100%  { -webkit-transform: rotateX(360deg); }}@-webkit-keyframes y-spin {0%    { -webkit-transform: rotateY(0deg); }50%   { -webkit-transform: rotateY(180deg); }100%  { -webkit-transform: rotateY(360deg); }}@-webkit-keyframes back-y-spin {0%    { -webkit-transform: rotateY(360deg); }50%   { -webkit-transform: rotateY(180deg); }100%  { -webkit-transform: rotateY(0deg); }}

html代码:

<div id="stage"><div id="rotate"><div id="ring-1" class="ring"></div><div id="ring-2" class="ring"></div><div id="ring-3" class="ring"></div></div>
</div>

js代码:

const POSTERS_PER_ROW = 12;
const RING_RADIUS = 200;function setup_posters (row){var posterAngle = 360 / POSTERS_PER_ROW;for (var i = 0; i < POSTERS_PER_ROW; i ++) {var poster = document.createElement('div');poster.className = 'poster';var transform = 'rotateY(' + (posterAngle * i) + 'deg) translateZ(' + RING_RADIUS + 'px)';poster.style.webkitTransform = transform;var content = poster.appendChild(document.createElement('p'));content.textContent = i;row.appendChild(poster);}
}function init (){setup_posters(document.getElementById('ring-1'));setup_posters(document.getElementById('ring-2'));setup_posters(document.getElementById('ring-3'));
}window.addEventListener('load', init, false);

参考地址:
CSS参考手册:animation
小tip: CSS3 animation渐进实现点点点等待提示效果

css3效果: animate实现点点点loading动画效果(一)相关推荐

  1. css loading 字体动画效果,CSS实现四种loading动画效果

    四种加载效果 /*第一种*/.demo1 { 4px; height: 4px; border-radius: 2px; background: #68b2ce;float: left; margin ...

  2. CSS3 animation实现点点点loading动画

    一.再续前缘 去年夏天,写了篇名为"CSS3 animation渐进实现点点点等待提示效果"的文章,主要内容是实现类似下面打点等待提示效果,比干巴巴的字符...要更人性化: 之前实 ...

  3. css3+jQuery制作导航菜单(带动画效果)

    <!DOCTYPE html> <html><head><meta charset="UTF-8"><title>css ...

  4. [Swift通天遁地]五、高级扩展-(11)图像加载Loading动画效果的自定义和缓存

    ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★ ➤微信公众号:山青咏芝(shanqingyongzhi) ➤博客园地址:山青咏芝(https://www.cnblog ...

  5. 游戏底特律:变人Loading动画效果实现

    1.需求描述 上周接到个好玩的任务,就是模仿游戏底特律人的loading动画效果,原始视频如下: 2.实现难点分析与概括: 由上面视频可以看出,此效果难点主要在缝隙的圆弧处理和缝隙的运动规律上.缝隙处 ...

  6. android Loading动画效果

    Android  Loading动画效果 现在项目不是很忙,所以想不能闲着,研究一下大神们是如何实现等待框中的动画显示的,之前看着效果那么帅,那么酷.比猫画虎的写了写代码. 首先在res文件夹下新建一 ...

  7. CSS3 transition实现超酷图片墙动画效果

    一.前面的感慨 以前也陆陆续续试过CSS3的一些特性,文字投影,多边框等.但都是试试而已,知道有这么回事.今天,见到了一个新玩意,transition,认认真真的试了一下,经过,我懵了,我呆了,我傻了 ...

  8. html中购物车小球飞入的效果,vue项目中css3实现加入购物车小球抛物线飞入动画效果...

    学习Vue中在做移动端商城练习项目时,记录css3实现加入购物车抛物线小球飞入动画效果.下面会介绍我在项目中实现抛物运动的简单方法. 知识点:css3动画(抛物线运动).vue动态绑定事件(控制小球出 ...

  9. css实现加载中loading动画效果

    1 效果 2 实现原理 原理很简单: 1 设置100px宽高的div,再设置成圆形border-radius:50%: 2 设置border一定宽度和颜色,再设置border-left为同样宽度和另一 ...

最新文章

  1. 《程序员代码面试指南》第五章 字符串问题 拼接所有字符串产生字典顺序最小的大写字符串...
  2. java启动子线程过多导致卡死_java线程基础巩固---多Product多Consumer之间的通讯导致出现程序假死的原因分析...
  3. Java语言的基础语法
  4. Mongodb百亿级数据添加,修改,删除,查询等性能测试【四】
  5. 作业三——原型化系统——外卖app
  6. c语言设计一个仿真窗口的程序,51单片机C语言实例(350例)Proteus仿真和代码
  7. java并发编程--一道经典多线程题的2种解法
  8. DP——背包问题(一)
  9. 桌面整理工具不显示文件夹_iOS14系统所下载的软件图标不显示在桌面怎么办?...
  10. 波士顿动力有对手了:不怕摔倒的机器狗,怎么踹都能站起来
  11. C语言编写FFT程序
  12. 传感器实验——蜂鸣器
  13. 详解KVM虚拟化原理
  14. matlab各种文件读写,Matlab的各种数据读取、文件读写等操作汇总
  15. 【信号与系统】(十三)傅里叶变换与频域分析——周期信号的傅里叶级数
  16. 欢迎体验 | Android 12 开发者预览版 3
  17. 斐讯k2虚拟服务器设置,斐讯K2调配设置
  18. php opc数据,OPC连接获取数据
  19. 电脑重装系统后,重启时遇到错误,报错需要重新启动,并重新安装系统
  20. 求不变矩matlab,求HU不变矩七个参数

热门文章

  1. 用有效的测试培养工程——《Growing Object-Oriented Software, Guided by Tests》读后感
  2. Transform组件C#游戏开发快速入门
  3. centos得mysql安装教程_Centos下Mysql安装图文教程_MySQL
  4. 攻破c语言笔试与机试难点,如何攻破C语言学习、笔试与机试的难点.doc
  5. html多重边框,中间空白,【基础】CSS实现多重边框的5种方式
  6. 在单链表写入一组数据代码_链表常见操作和15道常见面试题
  7. 自定义的代码块怎么移到别的电脑上
  8. 2022年度BCI奖 |THE ANNUAL BCI AWARD
  9. 牛津大学入学面试就这?组队选个颜色?背后的逻辑水深得很
  10. 拒收苹果超10万元赏金!程序员小哥找出iCloud账户漏洞后,发文直指苹果不够公开透明...