美文网首页
H5中关于animation的属性介绍

H5中关于animation的属性介绍

作者: __哈哈__ | 来源:发表于2016-10-27 20:52 被阅读253次

css3中的动画属性如果能够好好的使用,可以写出很多优美的动画

css-animation.PNG

关于 animation-direction

有两个值,默认为normal。意为一个动画结束之后,下一个动画周期从头开始接着动画播放。
另外一个值为alternate,意为动画结束之后,下一个动画周期从尾到头播放,再从头到尾播放。

关于 animation-play-state

paused 暂停
running 运行

关于 animation-fill-mode

html如下:

<div class="box"></div>

CSS如下:

.box{ transform: translateY(0);}
.box.on{ animation: move 1s;}
@keyframes move{ from{transform: translateY(-50px)} to {transform: translateY( 50px)}}

使用图片来表示 translateY 的值与 时间 的关系:
横轴为表示 时间,为 0 时表示动画开始的时间,也就是向 box 加上 on 类名的时间,横轴一格表示 0.5s
纵轴表示translateY的值,为 0 时表示 translateY的值为 0,纵轴一格表示 50px

animation-fill-mode: none

动画前后都没有设定动画前后都没有设定

animation-fill-mode: backwards

动画之前有一个设定动画之前有一个设定

animation-fill-mode: forwards

动画之后有一个设定动画之后有一个设定

animation-fill-mode: both

动画前后都有设定动画前后都有设定

动画小demo

html如下:

<div>haha</div>

css如下:

div{
    animation: myfirst 5s linear 2s infinite alternate;
    /* Firefox: */
    -moz-animation: myfirst 5s linear 2s infinite alternate;
    /* Safari 和 Chrome: */
    -webkit-animation: myfirst 5s linear 2s infinite alternate;
    /* Opera: */
    -o-animation: myfirst 5s linear 2s infinite alternate;
}

@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;}
}

相关文章

  • H5中关于animation的属性介绍

    css3中的动画属性如果能够好好的使用,可以写出很多优美的动画 关于 animation-direction 有两...

  • CSS3 之animation

    介绍 animation 属性是一个简写属性,用于设置六个动画属性: animation-name 规定需要绑定到...

  • CSS 动画

    css 动画可以产生多种效果,先简单介绍下 animation 的使用。 animation 属性 animati...

  • CSS3动画

    在CSS3中,动画效果使用animation属性来实现。animation属性和transition属性功能是相同...

  • 微信小程序-css动画

    一:css属性介绍 1、 animation:动画属性。详细的可查看官方APIwx.createAnimation...

  • day09

    A animation属性 B animation属性 C

  • iOS动画(二):核心动画中的基础移动(Swift)

    参考:第三篇:iOS动画系列之三:Core Animation。介绍了Core Animation的常用属性和方法...

  • animation

    animation是所有动画属性的简写,属性包括: animation-name使用简写属性animation可以...

  • 动画源码解析

    目录介绍 1.Animation和Animator区别 2.Animation运行原理和源码分析2.1 基本属性介...

  • animation

    animation(动画):animation属性是一个简写属性 animation-name:属性为@keyfr...

网友评论

      本文标题:H5中关于animation的属性介绍

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