1、animate介绍

1. @keyframes  自定义动画名称 {
from {
}
to {
}
} 2. 通过动画名称调用动画集
animation-name: 动画集名称。 3. 属性介绍:
/* 1. 通过动画集名称调用动画 */
animation-name: box_move;
/* 2.设置动画执行时间 */
animation-duration: 1s;
/* 3. 动画默认执行次数是1次, infinite: 无限次 */
animation-iteration-count: infinite;
/* 4. 设置动画的速度类型: ease ; */
animation-timing-function: linear;
/* 5. 设置延时执行时间 */
animation-delay: 2s;
/* 6. 设置动画逆播【动画怎么正着播放,倒着播放的时候也是一样的效果】 normal*/
animation-direction: alternate;
/* 7. 设置动画执行完后的一个状态: 让动画停在结束时候的状态 */
animation-fill-mode: forwards;
/* 8。 动画播放状态设置: running | paused暂停 */
animation-play-state: paused; 4. animation复合写法:
例如: animation: box_move 1s linear 2s alternate forwards;
注意:
1. 一个元素可以同时调用多个动画集,使用逗号隔开。
例如:
animation: box_move 1s,
one 1s linear 1s,
three 2s ease 5s alternate; 2. 可以将一个完整的动画分割成若干个阶段执行
@keyframes one {
0% {}
10% {}
20% {}
...
100%{}
}
百分比是相对整个动画执行时间而设置的。

2、案例

案例效果:盒子先水平向右移动100px;接下来向下移动100px,然后向左移动100px,最后向上移动100px又回到原点,其中每次改变方向都要变化背景颜色,循环往复执行

代码实现:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Document</title>
<style>
.box {
width: 30px;
height: 30px;
background-color: blue;
animation: move 8s linear infinite forwards;
}
@keyframes move {
from {
}
25% {
transform: translateX(100px);
background-color: red;
}
50% {
transform: translateX(100px) translateY(100px);
background-color: green;
}
75% {
transform: translateX(0px) translateY(100px);
background-color: yellow;
}
to {
transform: translateY(0px);
background-color: blue;
}
}
</style>
</head>
<body>
<div class="box"></div>
</body>
</html>

最新文章

  1. SQL 扩展事件
  2. C#操作word模板插入文字、图片及表格详细步骤
  3. 提高WPF程序性能的几条建议
  4. 人人都应该学习Markdown
  5. 蓝桥杯 入门训练 Fibonacci数列
  6. insert /*+APPEND*/ 各种insert 插入速度比较
  7. ASP.NET MVC 5 学习教程:生成的代码详解
  8. hdu 4920 Matrix multiplication(矩阵乘法)2014多培训学校5现场
  9. Qt Mac 在软件 icns图标制作
  10. express创建网站
  11. 关于定时发送服务的解决办法(PHP)
  12. 蓝桥杯- 煤球数目-java
  13. 在分布式数据库中CAP原理CAP+BASE
  14. C# 提前异步加载数据
  15. Netty 5 io.netty.util.IllegalReferenceCountException 异常
  16. 【翻译】asp.net core2.1认证和授权解密
  17. Android核心技术Intent和数据存储篇
  18. OC学习1——基本数据类型
  19. Python——多进程
  20. 手动释放和收缩tempdb

热门文章

  1. 批处理+7zip解压用纯数字加密的压缩包zip
  2. mjpg-streamer视频服务器移植
  3. 会话控制——Cookie和Session
  4. POJ 1177/HDU 1828 picture 线段树+离散化+扫描线 轮廓周长计算
  5. 了解facade设计模式
  6. RDD转为Dataset如何指定schema?
  7. AI 人工智能产业园路口-----dp
  8. 查看mysql表空间
  9. [ACTF2020 新生赛]Exec
  10. UVA - 12118 Inspector&#39;s Dilemma(检查员的难题)(欧拉回路)