自定义动画:

1.animation-name(自定义动画名称)

元素所应用的动画名称,必须与@keyframes使用,名称由@keyframes定义。

keyframes(动画关键帧):以@keyframes开头,其中{}所写入的是不同时间段的样式规则。

<style type="text/css">
.div { width: 100px;
  height: 100px;
  background: blue;
  animation-name: lefttoright;
} @keyframes lefttoright {      /*定义动画名称为lefttoright*/
         from {margin-left:0px;}      
         to {margin-left:300px;}
      }
</style>

2.animation-duration(动画时间)

<style type="text/css">
.div { width:100px;
  height: 100px;
   background:blue;
  animation-name:lefttoright;
  animation-duration: 3s;
}
@keyframes lefttoright { from {margin-left:}
to {margin-left: 300px;}
}

3.animation-timing-function(动画过渡速度类型)

linear:线性过渡

ease:平滑过渡

ease-in:由慢到快

ease-out:由快到慢

ease-in-out:由慢到快再到慢

<style type="text/css">
.div { width: 100px;
height: 100px;
background: blue;
animation-name: lefttoright;
animation-timing-function:ease-out; /*由快到慢*/
} @keyframes lefttoright { from {margin-left:}
to {margin-left: 300px;}
}
</style>

4.animation-delay:(动画延迟时间)

<style type="text/css">
.div { width: 100px;
height: 100px;
background: blue;
animation-name: lefttoright;
animation-timing-function:ease-out;
animation-delay:2s;
} @keyframes lefttoright { from {margin-left:}
to {margin-left: 300px;}
}
</style>

5.animation-iteration-count(动画执行次数)

<style type="text/css">
.div { width: 100px;
height: 100px;
background: blue;
animation-name: lefttoright;
animation-timing-function:ease-out;
animation-delay:2s;
animation-iteration-count:infinite;    /*无数次*/
} @keyframes lefttoright { from {margin-left:}
to {margin-left: 300px;} }
</style>

6.animation-direction(动画顺序)

normal:正常方向

reverse:反方向运动

alternate:先正常运动再反方向运动,并持续交替运动

aiternate-reverse:先反方向运动再正方向,并持续交替运动

<style type="text/css">
.div { width: 100px;
height: 100px;
background: blue;
animation-name: lefttoright;
animation-timing-function:ease-out;
animation-delay:2s;
animation-iteration-count:infinite;
animation-direction:alternate;    /*动画先正常运行再反方向运行,并持续交替运行*/
} @keyframes lefttoright { from {margin-left:}
to {margin-left: 300px;} }
</style>

7. animation-play-state(动画状态)

<style type="text/css">
.div { width:100px;
height: 100px;
background:blue;
animation-name:lefttoright;
animation-duration: 3s;
animation-timing-function:ease-in;
animation-delay:2s;
animation-iteration-count:infinite;
animation-direction:alternate;
animation-fill-mode: forwards;
} .div:hover { animation-play-state:paused; }    /*当鼠标移动到div中,动画暂停*/ @keyframes lefttoright { from {margin-left:}
to {margin-left: 300px;}
} </style>

8.animation-fill-mode(动画时间之外的状态)

none:默认值,不设置对象动画之外的状态

forwards:设置对象为动画结束时的状态

backwards:设置对象为动画开始时的状态

both:设置对象为动画开始或结束的状态

<style type="text/css">
.div { width: 100px;
height: 100px;
background: blue;
animation-name: lefttoright;
animation-timing-function:ease-out;
animation-delay:2s;
animation-iteration-count:infinite;
animation-direction:alternate;
animation-fill-mode: forwards;
} @keyframes lefttoright { from {margin-left:}
to {margin-left: 300px;} }
</style>

9.animation(动画复合属性)

语法:animation:[ animation-name ] || [ animation-duration ] || [ animation-timing-function ] || [ animation-delay ] || [animation-iteration-count ] || [ animation-direction ] || <single-animation-fill-mode> || <single-animation-play-state>

<style type="text/css">
.div{
width: 100px;
height: 100px;
background: blue;
animation:lefttoright 3s ease-out forwards;
} @keyframes lefttoright { from {margin-left:}
to {margin-left: 300px;}
}
</style>

自定义动画css属性的更多相关文章

  1. 深入学习jQuery自定义动画

    × 目录 [1]属性对象 [2]可选参数 [3]选项参数 前面的话 很多情况下,前面介绍的jQuery动画的简单效果无法满足用户的各种需求,那么就需要对动画有更多的限制,需要采取一些高级的自定义动画来 ...

  2. python全栈开发day48-jqurey自定义动画,jQuery属性操作,jQuery的文档操作,jQuery中的ajax

    一.昨日内容回顾 1.jQuery初识 1).使用jQuery而非JS的六大理由 2).jQuery对象和js对象转换 3).jQuery的两大特点 4).jQuery的入口函数三大写法 5).jQu ...

  3. 循序渐进BootstrapVue,开发公司门户网站(2)--- 使用wow.js动画组件以及自定义的CSS样式处理动态效果

    在我们开发的页面中,让页面有一些动画效果,可以让页面更加有吸引力,只要不是处理太过,一般人还是希望有一些动态效果,如滚动动画加载,悬停处理变化等效果,本篇随笔介绍使用wow.js动画组件以及自定义的C ...

  4. css属性的选择对动画性能的影响

    现在手机的占比越来越高,各种酷炫页面层出不穷,这些特效都离不开css动画.说到css动画,主流的情况也就无非这两大类:位移和形变.而我们在写一个动画特效的过程中,如何去提升它的性能呢?当然首先我们需要 ...

  5. css自定义动画在微信中无法执行的原因

    这是我去年年底遇到的一个问题, 在这个过程中我发现了一个比较有趣的问题. 我们在做抽奖的时候,微信分享到朋友圈的页面里,安卓机器无法执行页面中的自定义动画(元宝的位移,进入按钮的放大缩小等等).这让我 ...

  6. 容易忘记的css属性和动画属性

    动画属性 @keyframes 关键帧 --> animation 活泼 (配合使用) transform 变换 --> transition 过渡 (配合使用) 1.animation ...

  7. jquery动画控制非css属性

    JQuery的animate()方法可以通过渐变的更改CSS属性来实现简单的动画效果, 比如 $("#box").animate({height:"300px" ...

  8. css动画效果之transition(动画过渡效果属性)

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  9. CSS自定义动画

     动画名称  animation-name   :   (动画名称必须与@keyfarmes的名称相对应,因为动画名称是由@keyfarmes定义的) 例如:animation-name:AA:则 @ ...

随机推荐

  1. boost库的使用

    我的经验:在强调运行效率的场合:shared_ptr/weak_ptr很好用,尤其是weak_ptr这个能够判断一个对象的生命周期的玩意,可以简化和扩展很多设计.unordered系列的容器也很不错. ...

  2. [poj2411] Mondriaan's Dream (状压DP)

    状压DP Description Squares and rectangles fascinated the famous Dutch painter Piet Mondriaan. One nigh ...

  3. Xcode8 适配iOS10时遇见的一些问题

    1.证书管理 用Xcode8打开工程后,比较明显的就是下图了,这个是苹果的新特性,可以帮助我们自动管理证书.建议大家勾选这个Automatically manage signing(Ps.但是在bea ...

  4. Tomcat目录映射设置

    方法一: \conf\server.xml <Host>内插入<Context path="虚拟目录" docBase="文件目录" /> ...

  5. 用jQuery基于原生js封装的轮播

    我发现轮播在很多网站里面都用到过,一个绚丽的轮播可以为网页增色不少,最近闲来无事,也用原生js封装了一个轮播,可能不像网上的插件那么炫,但是也有用心去做.主要用了闭包的思想.需要传递的参数有:图片地址 ...

  6. iis设置asp站点

    在 IIS 6.0 中,默认设置是特别严格和安全的,这样可以最大限度地减少因以前太宽松的超时和限制而造成的攻击.譬如说默认配置数据库属性实施的最大 ASP 张贴大小为 204,800 个字节,并将各个 ...

  7. 泛型数组列表 ArrayList

    为什么使用泛型数组列表而不使用普通数组? 1.普通数组经常会发生容量太大以致浪费的情况 2.普通数组无法动态更改数组 基本概念: 1.采用[类型参数]的[类]---->[泛型类] 2.[泛型类型 ...

  8. 个人psp

    排球计分程序 1.计划 通过对用户故事估计这个任务需要3~5d天. 2.开发 2.1需求分析 作为一个观众,我希望了解每场比赛的比分,以便了解比赛的情况. 作为一个观众,我希望输入球队名称查询球队比分 ...

  9. 移动APP的开发迭代离不开测试,你搞清楚其中的关键点了吗?

    App测试的一个要求是一个beta测试环境.为此,操作系统制造商要么提供他们自己的测试环境,比如:Testflight (iOS),要么可以使用任一商用工具,如:HockeyApp (Android) ...

  10. 理解tcp协议的3次握手和面向连接

    1.tcp是有连接的, 这个不是说他有个实际的连接,这个是个虚拟的连接,连接的保持信息不是由连接的路线来保存的,他是由连接的两方来保存其状态信息,这就是面向连接的, 2.tcp要3次握手: 客户端发给 ...