# 一、帧动画
### 1、定义关键帧
```html
@keyframes 动画名称(英文) {
0% {
/* 动画的开始 */
}
25% {
/* 在25%的时候进行的一个动画 */
}
50% {
/* 在50%的时候进行的一个动画 */
}
100% {
/* 动画结束 */
}
}
from,to表示开始、结束状态,也可以使用0%,100%定义
@keyframes 动画名称(英文) {
from {
/* 动画开始 */
}
to {
/* 动画结束 */
}
}
```
### 2、引用帧动画
```html
animation: name duration timing-function delay iteration-count direction fill-mode;
animation: 动画名称 动画执行时间 动画速度曲线 延迟时间 动画播放次数 动画运动方向 动画结束之后显示的状态
注意:动画名称和动画执行时间必须写,否则动画无效
1.animation-name 动画名称 是定义关键帧是所定义的动画名称
2.animation-duration 动画的执行时间 单位:s/ms
3.animation-timing-function 规定动画运动的速度曲线
1.linear 相同的速度从开始到结束,也就是匀速
2.ease 默认值 慢速度开始--速度变快--慢速度结束
3.ease-in 慢速度开始的过渡效果,也就是以低速度开始
4.ease-out 慢速度结束的过渡效果,也就是以低速结束
5.ease-in-out 以慢速度开始和结束的过渡效果
4.animation-delay 定义动画何时开始
单位:s/ms
取值
- 以秒或毫秒计
- 默认值是 0
- 允许负值,(-2s 使动画马上开始,但跳过 2 秒进入动画)
5.animation-iteration-count 动画的执行次数
1.n 默认执行动画次数1次
2.infinite 无限次播放动画
6.animation-direction 定义是否应该轮流反向播放动画
1.normal 默认值,正常播放
2.alternate 动画轮流反向播放
3.alternate-reverse 从第一次就反向运动
7.animation-fill-mode d动画结束之后的显示状态
1.both:动画开始或结束的状态
2.fowards 动画结束时状态
3.backwards 动画开始的状态
8.animation-play-state: paused;动画播放方式 暂停
取值:
running:运动
paused: 暂停
```
## 二、animate.css动画插件
```html
https://animate.style/
https://www.dowebok.com/demo/2014/98/
css3动画库,预设了抖动(shake)、闪烁(flash)、弹跳(bounce)、旋转(rotateIn|rotateOut)、翻转(flip)、淡入淡出(fadeIn|fadeOut)等动画效果。
```
## 使用方法:
- 1、第一步. 引入animate.css文件
```
<link rel="stylesheet" href="css/animate.