美文网首页
动画模块

动画模块

作者: 小白古 | 来源:发表于2017-03-30 09:29 被阅读0次
<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <title>100-动画模块</title>
 <style>
 *{
 margin: 0;
 padding: 0;
 }
 div{
 width: 100px;
 height: 50px;
 background-color: red;
 /*transition-property: margin-left;*/
 /*transition-duration: 3s;*/

 /*1.告诉系统需要执行哪个动画*/
 animation-name: lnj;
 /*3.告诉系统动画持续的时长*/
 animation-duration: 3s;
 }
 /*2.告诉系统我们需要自己创建一个名称叫做lnj的动画*/
 @keyframes lnj {
 from{
 margin-left: 0;
 }
 to{
 margin-left: 500px;
 }
 }

 /*div:hover{*/
 /*margin-left: 500px;*/
 /*}*/
 </style>
</head>
<body>

1.过渡和动画之间的异同
1.1不同点
过渡必须人为的触发才会执行动画
动画不需要人为的触发就可以执行动画

1.2相同点
过渡和动画都是用来给元素添加动画的
过渡和动画都是系统新增的一些属性
过渡和动画都需要满足三要素才会有动画效果

<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <title>101-动画模块-其它属性上</title>
 <style>
 *{
 margin: 0;
 padding: 0;
 }
 div {
 width: 100px;
 height: 50px;
 background-color: red;
 animation-name: sport;
 animation-duration: 2s;
 /*告诉系统多少秒之后开始执行动画*/
 /*animation-delay: 2s;*/
 /*告诉系统动画执行的速度*/
 animation-timing-function: linear;
 /*告诉系统动画需要执行几次*/
 animation-iteration-count: 3;
 /*告诉系统是否需要执行往返动画
 取值:
 normal, 默认的取值, 执行完一次之后回到起点继续执行下一次
 alternate, 往返动画, 执行完一次之后往回执行下一次
 */
 animation-direction: alternate;
 }
 @keyframes sport {
 from{
 margin-left: 0;
 }
 to{
 margin-left: 500px;
 }
 }
 div:hover{
 /*
 告诉系统当前动画是否需要暂停
 取值:
 running: 执行动画
 paused: 暂停动画
 */
 animation-play-state: paused;
 }
 </style>
</head>
<body>
<div class="box1"></div>
</body>
</html>
其他属性
.box2{
            width: 200px;
            height: 200px;
            background-color: blue;
            margin: 100px auto;
            animation-name: myRotate;
            animation-duration: 5s;
            animation-delay: 2s;
            /*
            通过我们的观察, 动画是有一定的状态的
            1.等待状态
            2.执行状态
            3.结束状态
            */
            /*
            animation-fill-mode作用:
            指定动画等待状态和结束状态的样式
            取值:
            none: 不做任何改变
            forwards: 让元素结束状态保持动画最后一帧的样式
            backwards: 让元素等待状态的时候显示动画第一帧的样式
            both: 让元素等待状态显示动画第一帧的样式, 让元素结束状态保持动画最后一帧的样式
            */
            /*animation-fill-mode: backwards;*/
            /*animation-fill-mode: forwards;*/
            animation-fill-mode: both;
        }
        @keyframes myRotate {
            0%{
                transform: rotate(10deg);
            }
            50%{
                transform: rotate(50deg);
            }
            100%{
                transform: rotate(70deg);
            }
        }
动画模块连写格式
  • animation:动画名称 动画时长 动画运动速度 延迟时间 执行次数 往返动画;
动画模块连写格式的简写
  • animation:动画名称 动画时长;

相关文章

  • day21-CSS-动画模块

    动画模块 过渡模块和动画模块的异同 不同点 1.过渡模块需要人为触发(例如hover)才会执行动画 --- 过渡三...

  • 初识angular动画 之 angular-animations

    1. angular过渡动画初体验 安装动画模块 在 app.module.ts中引入动画模块BrowserAni...

  • 动画模块

    透明度 opacity: 数字;数字为0~1,为0透明看不见,为1完全不透明

  • 动画模块

    1.过渡和动画之间的异同 1.1不同点过渡必须人为的触发才会执行动画动画不需要人为的触发就可以执行动画 1.2相同...

  • 动画模块

    动画模块 格式:1.animation-name: asd;(取值是自己命名,告诉系统需要执行哪个动画) @key...

  • 动画模块

    1.过渡和动画之间的异同1.1不同点过渡必须人为的触发才会执行动画动画不需要人为的触发就可以执行动画 1.2相同点...

  • 2018-07-27 day10 Pygame模块

    Pygame模块 显示文字 显示图片 显示图形 动画

  • 读Zepto源码之Fx模块

    fx 模块为利用 CSS3 的过渡和动画的属性为 Zepto 提供了动画的功能,在 fx 模块中,只做了事件和样式...

  • 读Zepto源码之fx_methods模块

    fx 模块提供了 animate 动画方法,fx_methods 利用 animate 方法,提供一些常用的动画方...

  • 第四章——Animation动画模块使用

    4. Animation 动画模块的使用。 4.1 动画的介绍。 代码清单: 说明:这里的动画的一些接口在第一章中...

网友评论

      本文标题:动画模块

      本文链接:https://www.haomeiwen.com/subject/wkceottx.html