CSS3的过渡效果(transition)与动画(animation)
1.Transition
Transition是一种直观上的效果,让DOM元素的某个属性在固定时间内从一旧值到一新值。目前Firefox、Opera、Safari和Chrome都支持transition ,IE还不支持。
语法:transition: property duration timing-function delay;
transition-property 指定的要改变的css属性名称
transition-duration 指定过度效果要花多少时间(s/ms)
transition-timing-function 指定过渡效果的速度 ( linear ease ease-in ease-out ease-in-out cubic-bezier(n,n,n,n) )
| 值 | 描述 |
|---|---|
| linear | 规定以相同速度开始至结束的过渡效果(等于 cubic-bezier(0,0,1,1))。 |
| ease | 规定慢速开始,然后变快,然后慢速结束的过渡效果(cubic-bezier(0.25,0.1,0.25,1))。 |
| ease-in | 规定以慢速开始的过渡效果(等于 cubic-bezier(0.42,0,1,1))。 |
| ease-out | 规定以慢速结束的过渡效果(等于 cubic-bezier(0,0,0.58,1))。 |
| ease-in-out | 规定以慢速开始和结束的过渡效果(等于 cubic-bezier(0.42,0,0.58,1))。 |
| cubic-bezier(n,n,n,n) | 在 cubic-bezier 函数中定义自己的值。可能的值是 0 至 1 之间的数值。 |
.test{width:100px;height:100px;background:red;transition:width 2s,height 2s,background 2s;}
.test:hover{width:300px;height:300px;background:blue}
<div class="test"></div>
transition-delay 定义过渡效果的延迟时间
2. Animation
CSS动画(Animations)简单说就是在一段固定的动画时间内暗中在某一频率内改变其CSS某个或某些值,从而达到视觉上的转换动画效果。Animations的很多方面都是可以控制的,包括动画运行时间,开始值和结束值,还有动画的暂停和延迟其开始时间等。
目前支持Animation的浏览器有:Firefox、 Safari 和 Chrome,IE和Opera还不支持。
语法:animation: name duration timing-function delay iteration-count direction;
| 属性 | 描述 | CSS |
|---|---|---|
| @keyframes | 规定动画。 | 3 |
| animation | 所有动画属性的简写属性,除了 animation-play-state 属性。 | 3 |
| animation-name | 规定 @keyframes 动画的名称。 | 3 |
| animation-duration | 规定动画完成一个周期所花费的秒或毫秒。默认是 0。 | 3 |
| animation-timing-function | 规定动画的速度曲线。默认是 "ease"。 | 3 |
| animation-delay | 规定动画何时开始。默认是 0。 | 3 |
| animation-iteration-count | 规定动画被播放的次数。默认是 1。 | 3 |
| animation-direction | 规定动画是否在下一周期逆向地播放。默认是 "normal"。 | 3 |
| animation-play-state | 规定动画是否正在运行或暂停。默认是 "running"。 | 3 |
| animation-fill-mode | 规定对象动画时间之外的状态。 | 3 |
div.ani
{
width:100px;
height:100px;
background:red;
position:relative;
animation:mymove 5s infinite;
-webkit-animation:mymove 5s alternate infinite; /*Safari and Chrome*/
}
@-webkit-keyframes mymove /*Safari and Chrome*/
{
from {left:0px;}
to {left:200px;}
}
div.ani:hover{
-webkit-animation-play-state: paused;
}
<div class="ani"></div>
无缝滚动
<!DOCTYPE html >
<html>
<head>
<meta http-equiv="Content-Type" content="textml; charset=gb2312" />
<title>无标题文档</title>
<style>
* {
padding:;
margin:;
}
@-webkit-keyframes scrollText1 {
0% {
-webkit-transform: translateY(0px);
}
20% {
-webkit-transform: translateY(-30px);
}
40% {
-webkit-transform: translateY(-60px);
}
60% {
-webkit-transform: translateY(-90px);
}
80% {
-webkit-transform: translateY(-120px);
}
100% {
-webkit-transform: translateY(-150px);
}
}
.box3 {
position: relative;
top: 20px;
left: 20px;
width: 200px;
height: 30px;
line-height: 30px;
overflow: hidden;
border: 1px solid #ccc;
}
.border3 {
top: 0px;
-webkit-animation: scrollText1 10s infinite cubic-bezier(1, 0, 0.5, 0);
animation: scrollText1 10s infinite cubic-bezier(1, 0, 0.5, 0);
}
.border3 div {
height: 30px;
}
.border3:hover {
animation-play-state: paused;
-webkit-animation-play-state: paused;
}
</style>
</head>
<body>
<div class="box3">
<div class="border3">
<div>This is a test 1.</div>
<div>This is a test 2.</div>
<div>This is a test 3.</div>
<div>This is a test 4.</div>
<div>This is a test 5.</div>
<div>This is a test 1.</div>
</div>
</div>
</body>
<html>
CSS3的过渡效果(transition)与动画(animation)的更多相关文章
- CSS3实践之路(六):CSS3的过渡效果(transition)与动画(animation)
刚开始W3C CSS Workgroup拒绝将CSS3 transition与animation加入官方标准,一些成员认为过渡效果和动画并非样式属性,而且已经可以用脚本实现.所以请大家明白,特别是We ...
- CSS3的变形transform、过渡transition、动画animation学习
学习CSS3动画animation得先了解一些关于变形transform.过渡transition的知识 这些新属性大多在新版浏览器得到了支持,有些需要添加浏览器前缀(-webkit-.-moz-.- ...
- CSS过渡效果transition和动画
一.过渡效果 可以在不适用Flash和js 的情况下实现过渡效果 属性 描述 transition 简写属性,用于在一个属性中设置四个过渡属性 transition-property 规定应用过渡的c ...
- css3 变形(transform)、转换(transition)和动画(animation)
http://www.w3cplus.com/content/css3-transform/ 在CSS3中transform主要包括以下几种:旋转rotate.扭曲skew.缩放scale和移动tr ...
- css的过渡transition和动画animation
过渡 过渡(transition)是CSS3中具有颠覆性的特性之一,我们可以在不使用Flash动画或JavaScript的情况下,当元素从一种样式变换为另一种样式时元素添加效果.过渡动画:是从一个状态 ...
- css3中动画(transition)和过渡(animation)详析
css3中动画(transition)和过渡(animation)详析
- CSS动画 animation与transition
一.区分容易混淆的几个属性和值 先区分一下css中的几个属性:animation(动画).transition(过渡).transform(变形).translate(移动). CSS3中的trans ...
- IT兄弟连 HTML5教程 CSS3属性特效 动画-animation
CSS3属性中有关于制作动画的三个属性:Transform,Transition,Animation.前面已经介绍过Transform和Transition了,这里我们来学习Animation动画.通 ...
- css3基础教程十六变形与动画animation
前面我们讲过的变形与动画一般都是通过鼠标的单击.获得焦点,被点击或对元素进行一定改变后以后触发效果的,那么有没有像Flash一样自动播放的动画效果呢?答案当然是肯定的,这就是我们今天要讲到的anima ...
随机推荐
- microsoft visual studio 不能逐句执行?
最近在使用vs2013过程中,vs2013不能逐行执行,在不设断点的情况下,根本停不下来按一下F11,整个程序就执行完了.百度了很久也没找到方法(看的还不够仔细),卸载安装了很多次(看我够笨的吧),最 ...
- kafka配额控制
转载请注明地址http://www.cnblogs.com/dongxiao-yang/p/5217754.html Starting in 0.9, the Kafka cluster has th ...
- android生成二维码
新建项目 布局截图如下(一个输入框,一个按钮,一个imageview),输入想要的东西(文字,数字,网站链接等)然后点击按钮生成二维码,然后可以扫描识别. 首先需要一个谷歌的一个jar包 activi ...
- bzoj2132: 圈地计划
要分成两坨对吧.. 所以显然最小割 但是不兹辞啊.. 最小割是最小的啊 求最大费用怎么玩啊 那咱们就把所有费用都加起来,减掉一个最小的呗 但是两个属于不同集合的点贡献的价值是负的啊 网络流怎么跑负的啊 ...
- J2EE ssm框架-服务启动项内存加载数据及读取。
1.首先在 Web工程 WEB-INF目录下web.xml中添加 listener: <listener> <listener-class>com.founder.frame. ...
- visual studio 2015 企业版 序列号及官方下载地址
VisualStudio 2015 正式版已经可以通过官方下载了. Visual Studio 是一套基于组件的软件开发工具和其他技术,可用于构建功能强大.性能出众的应用程序.Visual Studi ...
- 构建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统(41)-组织架构
原文:构建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统(41)-组织架构 本节开始我们要实现工作流,此工作流可以和之前的所有章节脱离关系,也可以紧密合并. 我们当 ...
- [RxJS] Filtering operators: skipWhile and skipUntil
After takeUntil() and takeWhile() function, let's have a look on skipWhile() and skilUntil() functio ...
- 怎样创建TWaver 3D的轮廓选中效果
在一般的游戏中.物体的选中效果会是这样: TWaver 3D中,物体的默认的选中效果一般都是一个方方正正的外框.在HTML5的Mono版本号中,TWaver提供了轮廓线样式的选中效果. 通过例如以下代 ...
- ZFS+Dtrace+Zones+KVM=SMARTOS + dtrace 详细文档
https://smartos.org/ http://dtrace.org/guide/chp-io.html http://blog.csdn.net/babyfacer/article/deta ...