Animations功能(区别于Transitions)

时间:2022-04-21 20:27:01

CSS3实现动画:

1  Transitions:定义元素的某个属性从一个属性值平滑过渡到另一个属性值。

Transitions属性的使用方法如下所示:

transition: property | duration  | timing-function | delay

transition-property: 表示对那个属性进行平滑过渡。

transition-duration: 表示在多长时间内完成属性值的平滑过渡。

transition-timing-function 表示通过什么方法来进行平滑过渡。

transition-delay: 定义过渡动画延迟的时间。

默认值是 all  0  ease  0

浏览器支持程度:IE10,firefox4+,opera10+,safari3+及chrome8+

实例1:

HTML:

 <div id="transBox" class="trans_box">
<div class="trans_list ease">ease</div>
<div class="trans_list ease_in">ease-in</div>
<div class="trans_list ease_out">ease-out</div>
<div class="trans_list ease_in_out">ease-in-out</div>
<div class="trans_list linear">linear</div>
</div>

CSS:

 .trans_box {
background-color: #f0f3f9;
  width:100%
}
.trans_list {
width: 30%;
height: 50px;
margin:10px 0;
background-color:blue;
color:#fff;
text-align:center;
}
.ease {
-webkit-transition: all 4s ease;
-moz-transition: all 4s ease;
-o-transition: all 4s ease;
transition: all 4s ease;
}
.ease_in {
-webkit-transition: all 4s ease-in;
-moz-transition: all 4s ease-in;
-o-transition: all 4s ease-in;
transition: all 4s ease-in;
}
.ease_out {
-webkit-transition: all 4s ease-out;
-moz-transition: all 4s ease-out;
-o-transition: all 4s ease-out;
transition: all 4s ease-out;
}
.ease_in_out {
-webkit-transition: all 4s ease-in-out;
-moz-transition: all 4s ease-in-out;
-o-transition: all 4s ease-in-out;
transition: all 4s ease-in-out;
}
.linear {
-webkit-transition: all 4s linear;
-moz-transition: all 4s linear;
-o-transition: all 4s linear;
transition: all 4s linear;
}
.trans_box:hover .trans_list{
margin-left:90%;
background-color:#beceeb;
color:#333;
-webkit-border-radius:25px;
-moz-border-radius:25px;
-o-border-radius:25px;
border-radius:25px;
-webkit-transform: rotate(360deg);
-moz-transform: rotate(360deg);
-o-transform: rotate(360deg);
transform: rotate(360deg);
}

demo演示如下:

ease
ease-in
ease-out
ease-in-out
linear

* 可以为平滑过渡设置多个属性值。

实例2:

HTML:

<div class="transitions2">transitions平滑过渡多个属性值</div>

CSS :

 .transitions2 {
background-color:#ffff00;
color:#000000;
width:300px;
-webkit-transition: background-color 1s linear, color 1s linear, width 1s linear;
-moz-transition: background-color 1s linear, color 1s linear, width 1s linear;
-o-transition: background-color 1s linear, color 1s linear, width 1s linear;
}
.transitions2:hover {
background-color: #003366;
color: #ffffff;
width:400px;
}

demo演示如下:

transitions平滑过渡多个属性值

2 Animations:

      可以通过定义多个关键帧以及定义每个关键帧中元素的额属性值来实现更为复杂的动画效果。

语法:animations: name duration timing-function iteration-count;

name: 关键帧集合名(通过此名创建关键帧的集合)

duration: 表示在多长时间内完成属性值的平滑过渡

timing-function: 表示通过什么方法来进行平滑过渡

iteration-count: 迭代循环次数,可设置为具体数值,或者设置为infinite进行无限循环,默认为1.

用法:@-webkit-keyframes 关键帧的集合名 {创建关键帧的代码}

实例:

HTML:

<div class="animate">使用animate实现更为复杂的动画</div>

CSS:

 .animate {background-color:red;height:100px;}
@-webkit-keyframes mycolor {
0% {background-color:red;}
40% {background-color:darkblue;}
70% {background-color: yellow;}
100% {background-color:red;}
}
@-moz-keyframes mycolor {
0% {background-color:red;}
40% {background-color:darkblue;}
70% {background-color: yellow;}
100% {background-color:red;}
} .animate:hover {
-webkit-animation-name: mycolor;
-webkit-animation-duration: 5s;
-webkit-animation-timing-function:linear; -moz-animation-name: mycolor;
-moz-animation-duration: 5s;
-moz-animation-timing-function:linear;
}

演示demo如下:

使用animate实现更为复杂的动画

(感谢-空智)

Animations功能(区别于Transitions)的更多相关文章

  1. Win10家庭版、专业版、企业版、教育版各版本功能区别对照表

    关于Win10系统的版本问题,MS酋长之前曾经分享过Windows10有哪些版本,在这篇文章中简单地介绍了一下Win10各版本的功能区别及适宜用户群,但是并没有对各版本的功能区别做一详细的对比.日前微 ...

  2. 新版微耕软件&lpar;N3000)与旧版2000的实体功能区别

    更多细节请参阅其软件操作说明书. 建议:基于安全的应用始终变化不断,软件投入一直无法满足客户的定制化要求.不如提供基本的SDK,接口,允许第三方以插件的形式开发控制界面.报表. 软件只提供核心的界面. ...

  3. Qt5&period;3企业版和开源版功能区别

    一: Charts Charts是QT提供的图表模块.他提供了非常简便的APIs来绘制令人惊叹的Line, Spline,Area,Scatter,Pie,Donut,Bar,Polar和Box-an ...

  4. BT下载器Folx中删除任务与删除文件的功能区别

    当用户使用Folx完成了任务下载后,该任务仍会保留在下载列表中,并标注"已结束"的标记.随着使用时间的增长,Folx下载列表中会包含过多的"已结束"任务,用户需 ...

  5. C语言break&sol;continue&sol;exit&sol;return的功能区别

    break是跳出整个循环而执行循环体之外的下一条语句: continue只是跳出本次循环继续判断下一次循环条件是否满足. exit() 结束当前进程/当前程式/,在整个程式中,只要调用 exit ,就 ...

  6. HTML5与CSS3权威指南&period;pdf8

    第17章 与背景和边框相关的样式 与背景相关的新增属性 background-clip指定背景的显示范围 background-origin指定绘制背景图像时的起点 background-size指定 ...

  7. css3动画功能介绍

    一:过渡动画---Transitions 含义:在css3中,Transitions功能通过将元素的某个属性从一个属性值在指定的时间内平滑过渡到另一个属性值来实现动画功能. Transitions属性 ...

  8. CSS3中的动画功能(一)

    css3中的动画功能分为transitions功能和animations功能,这两种功能都可以通过改变css属性值来产生动画效果.今天带大家一起来看看css3动画功能中的transitions的用法. ...

  9. CSS3基础&lpar;2&rpar;—— 文字与字体相关样式、盒子类型、背景与边框相关样式、变形处理、动画功能

    一. CSS3 文字与字体相关样式 1. 给文字添加阴影 text-shadow: length length length ccolor; 属性适用于文本阴影,指定了水平阴影,垂直阴影,模糊的距离, ...

随机推荐

  1. python统计列表内元素个数

    代码如下: list01 = ['a','b','c','a','c'] set01 = set(list01) print(set01) dict01 = {} for item in set01: ...

  2. poj1014 dp 多重背包

    //Accepted 624 KB 16 ms //dp 背包 多重背包 #include <cstdio> #include <cstring> #include <i ...

  3. 在Web上调用Ocx控件

    原文:http://blog.csdn.net/goodadult2012/article/details/6343369 在HTML页面中使用ActiveX控件包含三个基本操作:将控件放入HTML中 ...

  4. 读&lt&semi;&lt&semi;CLR via C&num;&gt&semi;&gt&semi; 详谈泛型

    1,什么是泛型? 答:泛型是类型的模板,类型是实例(对象)的模板.C#提供了5种泛型:类,接口,委托,结构和方法. 2,使用泛型有什么好处? 答:继承实现的是"代码重用",而泛型实 ...

  5. H2O与Java线程同步

    Java 5以前的线程同步采用syncronized和wait,notify,notifyAll来实现,比较粗糙.之后有了Lock和Condition.ReentrantLock的简单lock,unl ...

  6. offsetParent和parentNode区别

    offsetParent用的最普遍的就是来计算元素在页面中的位置,前面的日志理讲了 通过getBoundingClientRect() 来获取页面中元素的位置,不过这只支持最新的浏览器,如果要兼容像O ...

  7. HDU 4951 Multiplication table 阅读题

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=4951 题意:给一个P进制的乘法表.行和列分别代表0~p-1,第i行第j*2+1和第j*2+2列代表的是第i ...

  8. &lpar;原创&rpar;ubuntu 10&period;04&plus;ruby1&period;9&period;2&plus;rails3 安装记录

    第一步当然是现在ruby 1.9.2 的sourcecode了,因为现在的ubuntu 源中还没有1.9.2的版本 我下载的是ruby-1.9.2-p290.tar.gz 然后解压到/usr/loca ...

  9. 【转载】PhpStudy修改Apache的端口号

    phpStudy是一个PHP调试环境的程序集成包.该程序包集成最新的Apache+PHP+MySQL+phpMyAdmin+ZendOptimizer,一次性安装,无须配置即可使用,是非常方便.好用的 ...

  10. 设计模式,python延迟计算缓存模式

    之前已经发过单独的缓存,这也算一种模式. from __future__ import print_function import functools class lazy_property(obje ...