Animations功能(区别于Transitions)
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演示如下:
* 可以为平滑过渡设置多个属性值。
实例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演示如下:
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如下:
Animations功能(区别于Transitions)的更多相关文章
- Win10家庭版、专业版、企业版、教育版各版本功能区别对照表
关于Win10系统的版本问题,MS酋长之前曾经分享过Windows10有哪些版本,在这篇文章中简单地介绍了一下Win10各版本的功能区别及适宜用户群,但是并没有对各版本的功能区别做一详细的对比.日前微 ...
- 新版微耕软件(N3000)与旧版2000的实体功能区别
更多细节请参阅其软件操作说明书. 建议:基于安全的应用始终变化不断,软件投入一直无法满足客户的定制化要求.不如提供基本的SDK,接口,允许第三方以插件的形式开发控制界面.报表. 软件只提供核心的界面. ...
- Qt5.3企业版和开源版功能区别
一: Charts Charts是QT提供的图表模块.他提供了非常简便的APIs来绘制令人惊叹的Line, Spline,Area,Scatter,Pie,Donut,Bar,Polar和Box-an ...
- BT下载器Folx中删除任务与删除文件的功能区别
当用户使用Folx完成了任务下载后,该任务仍会保留在下载列表中,并标注"已结束"的标记.随着使用时间的增长,Folx下载列表中会包含过多的"已结束"任务,用户需 ...
- 意味着JNPF迈入新时代的3.4版本,与3.3.3版本有着哪些功能区别呢?
在线开发 3.3.3版本 同一个功能分功能设计和移动设计 功能设计没有更换模式 功能设计没有同步菜单 功能设计和移动设计无表模式 3.4.1版本 同一个功能可以在功能设计里面设计,根据客户需求自己选 ...
- C语言break/continue/exit/return的功能区别
break是跳出整个循环而执行循环体之外的下一条语句: continue只是跳出本次循环继续判断下一次循环条件是否满足. exit() 结束当前进程/当前程式/,在整个程式中,只要调用 exit ,就 ...
- HTML5与CSS3权威指南.pdf8
第17章 与背景和边框相关的样式 与背景相关的新增属性 background-clip指定背景的显示范围 background-origin指定绘制背景图像时的起点 background-size指定 ...
- css3动画功能介绍
一:过渡动画---Transitions 含义:在css3中,Transitions功能通过将元素的某个属性从一个属性值在指定的时间内平滑过渡到另一个属性值来实现动画功能. Transitions属性 ...
- CSS3中的动画功能(一)
css3中的动画功能分为transitions功能和animations功能,这两种功能都可以通过改变css属性值来产生动画效果.今天带大家一起来看看css3动画功能中的transitions的用法. ...
随机推荐
- JavaScript高级应用(一)
1.尺寸 //各种尺寸 s += "\r\n网页可见区域宽(document.body.clientWidth):"+ document.body.clientWidth; s + ...
- abort终止正在进行中的的ajax请求
核心:调用XMLHttpRequest对象上的abort方法 jQuery的ajax方法有自己的超时时间设置参数: $.ajax({type:'POST', url:'b.php', data:' ...
- linux passwd文件解析
#cat/etc/passwd root:x:::Superuser:/: daemon:x:::Systemdaemons:/etc: bin:x:::Ownerofsystemcommands:/ ...
- Spring Boot Admin 的使用 2
http://blog.csdn.net/kinginblue/article/details/52132113 ******************************************* ...
- c++ 在windows下建立目录
#include <direct.h> #include <stdlib.h> #include <stdio.h> int main( void ) { ) { ...
- 将java源文件制成jar包
很多人都在苦恼,如何将写好的程序代码能在日后随时调用和配置在项目中运行 今天,就让梦逸来给大家分享这个过程 首先,创建好一个文件夹,文件夹名称随意 这个文件夹中是用来存放java源文件( 未编译的 x ...
- yii2-basic后台管理功能开发之一:引入模板
前景:哎没想到用php的yii2框架写了官网……自己选择的框架,跪着也要码完,当年用yii2-basic搭建了官网,原是想偷懒的,没想到还要写后台.... 需求:实现一个可编辑页面图片及新闻内容的后台 ...
- OllyDBG 1.10
OllyDBG 1.10 OllyDBG.exeOllyDBG SoftICE文件->打开 (快捷键是 F3)F2 断点 F9F8 步过 F10F7 步入 F8F4 运行到位置 F7F9 运行 ...
- Javascript之运动框架2
运动框架2与运动框架1的不同之处在于,运动框架2是框架1的升级版,首先完善了传入值,改为move(obj,json,options),在options里面,可以选择传入或者不传入时间,运动形式,以及函 ...
- Objective-C( Foundation框架 一 常见的结构体)
常见的结构体 (NSPoint,CGPoint).(NSRange,CGRange).(NSSize,CGSize) 苹果官方推荐使用CG开头的结构体 NSRange是Foundation框架中常见的 ...