CSS动画框架Loaders.css +animate.css
CSS加载动画框架Loaders.css
是一款非常出色的加载动画框架,Loaders.css利用纯CSS可以实现很多种样式的Loading加载动画,这些动画并不需要图片来辅助,而是仅仅需要CSS即可实现,因此运行效率比较不错。
Loaders.css的特点
- 基于纯CSS,不需JavaScript脚本,也不需要图片,很干净。
- 默认提供近30个不同的Loading动画效果,你也可以发挥自己的想象来实现不同的加载动画。
- Loaders.css比较轻巧,基本没什么臃肿的文件。
- 免费、开源,这是必须的。
下面是第一行第4个Loading动画的CSS代码,其他的大家可以在源代码中查看。
<span class= "hljs-selector-class" >.ball-clip-rotate-pulse { <span class= "hljs-attribute" > position : relative ; <span class= "hljs-attribute" >-webkit-transform: <span class= "hljs-built_in" >translateY( -15px ); <span class= "hljs-attribute" >-ms-transform: <span class= "hljs-built_in" >translateY( -15px ); <span class= "hljs-attribute" >transform: <span class= "hljs-built_in" >translateY( -15px ); } <span class= "hljs-comment" > /* line 262, stdin */ <span class= "hljs-selector-class" >.ball-clip-rotate-pulse > <span class= "hljs-selector-tag" >div { <span class= "hljs-attribute" >-webkit-animation-fill-mode: both ; <span class= "hljs-attribute" >animation-fill-mode: both ; <span class= "hljs-attribute" > position : absolute ; <span class= "hljs-attribute" > top : <span class= "hljs-number" > 0px ; <span class= "hljs-attribute" > left : <span class= "hljs-number" > 0px ; <span class= "hljs-attribute" >border-radius: <span class= "hljs-number" > 100% ; } <span class= "hljs-comment" > /* line 269, stdin */ <span class= "hljs-selector-class" >.ball-clip-rotate-pulse > <span class= "hljs-selector-tag" >div<span class= "hljs-selector-pseudo" >:first-child { <span class= "hljs-attribute" > background : <span class= "hljs-number" > #fff ; <span class= "hljs-attribute" > height : <span class= "hljs-number" > 16px ; <span class= "hljs-attribute" > width : <span class= "hljs-number" > 16px ; <span class= "hljs-attribute" > top : <span class= "hljs-number" > 9px ; <span class= "hljs-attribute" > left : <span class= "hljs-number" > 9px ; <span class= "hljs-attribute" >-webkit-animation: scale <span class= "hljs-number" > 1 s <span class= "hljs-number" > 0 s <span class= "hljs-built_in" >cubic-bezier( 0.09 , 0.57 , 0.49 , 0.9 ) infinite; <span class= "hljs-attribute" >animation: scale <span class= "hljs-number" > 1 s <span class= "hljs-number" > 0 s <span class= "hljs-built_in" >cubic-bezier( 0.09 , 0.57 , 0.49 , 0.9 ) infinite; } <span class= "hljs-comment" > /* line 277, stdin */ <span class= "hljs-selector-class" >.ball-clip-rotate-pulse > <span class= "hljs-selector-tag" >div<span class= "hljs-selector-pseudo" >:last-child { <span class= "hljs-attribute" > position : absolute ; <span class= "hljs-attribute" > border : <span class= "hljs-number" > 2px solid <span class= "hljs-number" > #fff ; <span class= "hljs-attribute" > width : <span class= "hljs-number" > 30px ; <span class= "hljs-attribute" > height : <span class= "hljs-number" > 30px ; <span class= "hljs-attribute" > background : transparent ; <span class= "hljs-attribute" > border : <span class= "hljs-number" > 2px solid ; <span class= "hljs-attribute" > border-color : <span class= "hljs-number" > #fff transparent <span class= "hljs-number" > #fff transparent ; <span class= "hljs-attribute" >-webkit-animation: rotate <span class= "hljs-number" > 1 s <span class= "hljs-number" > 0 s <span class= "hljs-built_in" >cubic-bezier( 0.09 , 0.57 , 0.49 , 0.9 ) infinite; <span class= "hljs-attribute" >animation: rotate <span class= "hljs-number" > 1 s <span class= "hljs-number" > 0 s <span class= "hljs-built_in" >cubic-bezier( 0.09 , 0.57 , 0.49 , 0.9 ) infinite; <span class= "hljs-attribute" >-webkit-animation-duration: <span class= "hljs-number" > 1 s; <span class= "hljs-attribute" >animation-duration: <span class= "hljs-number" > 1 s; }</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> |
在线演示地址:http://static.codeceo.com/demo/201505/loaders.css/index.html
GitHub地址:https://github.com/ConnorAtherton/loaders.css
软件首页:https://connoratherton.com/loaders
animate.css
animate.css是一个使用CSS3的animation制作的动画效果的CSS集合,里面预设了很多种常用的动画,且使用非常简单。本文将详细介绍animate.css的使用
引入
animate.css的最新版本是3.5.2,引入animate.css很容易,有以下几种方法
1、从官网下载
https://raw.github.com/daneden/animate.css/master/animate.css
2、通过npm安装
$ npm install animate.css
3、使用在线cdn
https://unpkg.com/animate.css@3.5.2/animate.min.css
效果演示
animate.css的使用非常简单,因为它是把不同的动画绑定到了不同的类里,所以想要使用哪种动画,只需要把通用类animated和相应的类添加到元素上就行了
下面来详细介绍animate.css里面的类,主要包括Attention(晃动效果)、bounce(弹性缓冲效果)、fade(透明度变化效果)、flip(翻转效果)、rotate(旋转效果)、slide(滑动效果)、zoom(变焦效果)、special(特殊效果)这8类
【Attention(晃动效果)】

bounce
flash
pulse
rubberBand
shake
headShake
swing
tada
wobble
jello

以在div上使用bounce为例
<div class="animated bounce"></div>
【bounce(弹性缓冲效果)】

bounceIn
bounceInDown
bounceInLeft
bounceInRight
bounceInUp
bounceOut
bounceOutDown
bounceOutLeft
bounceOutRight
bounceOutUp

【fade(透明度变化效果)】

fadeIn
fadeInDown
fadeInDownBig
fadeInLeft
fadeInLeftBig
fadeInRight
fadeInRightBig
fadeInUp
fadeInUpBig
fadeOut
fadeOutDown
fadeOutDownBig
fadeOutLeft
fadeOutLeftBig
fadeOutRight
fadeOutRightBig
fadeOutUp
fadeOutUpBig

【flip(翻转效果)】
flip
flipInX
flipInY
flipOutX
flipOutY
【rotate(旋转效果)】

rotateIn
rotateInDownLeft
rotateInDownRight
rotateInUpLeft
rotateInUpRight
rotateOut
rotateOutDownLeft
rotateOutDownRight
rotateOutUpLeft
rotateOutUpRight

【slide(滑动效果)】

slideInDown
slideInLeft
slideInRight
slideInUp
slideOutDown
slideOutLeft
slideOutRight
slideOutUp

【zoom(变焦效果)】

zoomIn
zoomInDown
zoomInLeft
zoomInRight
zoomInUp
zoomOut
zoomOutDown
zoomOutLeft
zoomOutRight
zoomOutUp

【special(特殊效果)】
hinge
rollIn
rollOut
lightSpeedIn
lightSpeedOut
实际应用
在一般的使用中,直接在元素上添加animated和对应的类名即可

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" href="https://unpkg.com/animate.css@3.5.2/animate.min.css">
<style>
.box{height: 100px;width: 100px;background-color: lightblue}
</style>
</head>
<body>
<div class="box animated flash"></div>
</body>
</html>


通过给JS添加或删除class,可以实现动态效果

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" href="https://unpkg.com/animate.css@3.5.2/animate.min.css">
<style>
.box{height: 100px;width: 100px;background-color: lightblue}
</style>
</head>
<body>
<button id="btn1">添加</button>
<button id="btn2">移除</button>
<div id="box" class="box"></div>
<script>
var oBtn1 = document.getElementById('btn1');
var oBtn2 = document.getElementById('btn2');
var oBox = document.getElementById('box');
oBtn1.onclick = function(){
oBox.classList.add('animated');
oBox.classList.add('flash');
}
oBtn2.onclick = function(){
oBox.classList.remove('flash');
}
</script>
</body>
</html>

至于动画的配置参数,比如动画持续时间,动画的执行次数等等,可以在元素上自行定义,覆盖掉animate.css里面所定义的就行了

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" href="https://unpkg.com/animate.css@3.5.2/animate.min.css">
<style>
.box{height: 100px;width: 100px;background-color: lightblue}
.infinite{animation-iteration-count:infinite;}
</style>
</head>
<body>
<button id="btn1">添加循环的动画效果</button>
<button id="btn2">移除</button>
<div id="box" class="box"></div>
<script>
var oBtn1 = document.getElementById('btn1');
var oBtn2 = document.getElementById('btn2');
var oBox = document.getElementById('box');
oBtn1.onclick = function(){
oBox.classList.add('animated');
oBox.classList.add('flash');
oBox.classList.add('infinite');
}
oBtn2.onclick = function(){
oBox.classList.remove('flash');
}
</script>
</body>
</html>

CSS动画框架Loaders.css +animate.css的更多相关文章
- CSS3动画animation认识,animate.css的使用
CSS动画 可以取代js动画 在移动端会更加流畅! 下面是一个的绘制太阳系各大行星运行轨迹笔记,可以自学参考! -------------------------------------------- ...
- Web高性能动画及渲染原理(1)CSS动画和JS动画
目录 一. CSS动画 和 JS动画 1.1 CSS动画 1.2 JS动画 1.3 小结 二. 使用Velocity.js实现动画 示例代码托管在:http://www.github.com/dash ...
- 高性能Web动画和渲染原理系列(1)——CSS动画和JS动画
[摘要] 介绍CSS动画和JS动画的基本特点,以及轻量级动画库velocity.js的基本用法. 示例代码托管在:http://www.github.com/dashnowords/blogs 博客园 ...
- 【JavaScript框架封装】实现一个类似于JQuery的基础框架、事件框架、CSS框架、属性框架、内容框架、动画框架整体架构的搭建
/* * @Author: 我爱科技论坛 * @Time: 20180715 * @Desc: 实现一个类似于JQuery功能的框架 * V 1.0: 实现了基础框架.事件框架.CSS框架.属性框架. ...
- Ionic3学习笔记(五)动画之使用 animate.css
本文为原创文章,转载请标明出处 目录 前言 animate.css 的使用 animate.scss 的使用 1. 前言 animate.css 是一款强大的.跨浏览器的预设CSS3动画库,内置了很多 ...
- CSS--使用Animate.css制作动画效果
一 使用Animate.css动画 // 通过@import引入外部CSS资源; // 引入线上图片及JS文件; // 通过更改CSS类名生成不同类型的CSS3动画; <!DOCTYPE h ...
- animate.css的使用
前面的话 animate.css是一个使用CSS3的animation制作的动画效果的CSS集合,里面预设了很多种常用的动画,且使用非常简单.本文将详细介绍animate.css的使用 引入 anim ...
- Animate.css介绍
Animate.css简介 animate.css 动画库,预设了抖动(shake).闪烁(flash).弹跳(bounce).翻转(flip).旋转(rotateIn/rotateOut).淡入淡出 ...
- 强大的CSS3动画库animate.css
今天要给大家介绍一款强大的CSS3动画库animate.css,animate.css定义了大概50多种动画形式,包括淡入淡出,文字飞入.左右摇摆动画等等.使用animate.css也非常简单,你可以 ...
随机推荐
- Python基本语法(基于3.x)
Python的两种运行模式: 命令行模式,运行python,然后在命令行中输入python命令 程序脚本, 在命令行中输入 ./hello.py运行 Python是解释形语言,但可以通过工具打包成二进 ...
- ES6 | class类的基本语法总结
类和模块的内部,默认就是严格模式,所以不需要使用use strict指定运行模式.只要你的代码写在类或模块之中,就只有严格模式可用. 考虑到未来所有的代码,其实都是运行在模块之中,所以 ES6 实际上 ...
- 关于 jsp java servlet 中文汉字乱码的解决方法
在servlet类中的get,post最前面加上 req.setCharacterEncoding("UTF-8"); resp.setCharacterEncoding(&quo ...
- 一个PHPer如何深入学习ES搜索引擎?
公司早在一年前就上ES作为后端搜索服务的项目 ,我们PHPer只是负责实现业务接口,es的一些查询,优化技巧由另一组同事(JAVAer)负责,有时,一个需求过来,改动较大时,需要更改查询json语句, ...
- e.Row.Attributes.Add
其实看到属性这个单词,还有点发憷呢,C#里面有个关键词是Attributes, 搞了半天貌似没有弄清楚 e.Row.Attributes.Add()函数的介绍,包括参数,什么是Attributes 就 ...
- RocketMQ学习笔记(5)----RocketMQ监控平台rocketmq-console-ng的搭建
1. 下载rocketmq-console-ng 官网地址:https://github.com/apache/rocketmq-externals 拉下来之后,使用idea打开rocketmq-co ...
- H5教程:移动页面性能优化
随着移动互联网的发展,我们越发要关注移动页面的性能优化,今天跟大家谈谈这方面的事情. 首先,为什么要最移动页面进行优化? 纵观目前移动网络的现状,移动页面布局越来越复杂,效果越来越炫,直接导致了文件越 ...
- [USACO10FEB]吃巧克力Chocolate Eating
题目:洛谷P2985. 题目大意:有n块巧克力要吃d天,并且只能按顺序吃.一块巧克力有一个开心值,吃了就能增加开心值.一个人初始开心值为0,且每天早上开心值变为原来的一半.问如何吃巧克力才能使开心值最 ...
- 题解 洛谷 P3381 【【模板】最小费用最大流】
发了网络流,再来一发费用流 能做费用流的,网络流自然做得来,但在这还是不要脸的安利一下自己的博客(里面也有网络流的题解): 点我 扯远了... 费用流,就是在不炸水管的情况下求源点到汇点的最小费用. ...
- 题解 P3372 【【模板】线段树1 】(zkw)
看了一下题解里的zkw线段树,感觉讲的不是很清楚啊(可能有清楚的但是我没翻到,望大佬勿怪). 决定自己写一篇...希望大家能看明白... zkw线段树是一种优秀的非递归线段树,速度比普通线段树快两道三 ...