CSS3-过渡属性
transition: property duration timing-function delay;
transition-property:过渡属性的名称
none 没有过渡属性
all 所有属性都过渡(默认值)
property 具体属性名称(property1,property2...)
transition-duration:过渡属性花费的时间
time 秒或毫秒
transition-timing-function:过渡效果速度曲线
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 之间的数值。
transition-delay:过渡效果延迟时间
time 秒或毫秒
过渡完成事件:
Webkit内核: obj.addEventListener('webkitTransitionEnd',function(){});
标准:obj.addEventListener('transitionend',function(){});
CSS3-动画
animation: name duration timing-function delay iteration-count direction;
animation-name: 动画名称
animation-name: keyframename|none;
keyframename 自定义的名字
none 无动画效果
animation-duration: 动画执行时间
animation-duration: time;
time 秒或毫秒
animation-timing-function: 动画速度曲线
animation-timing-function: value;
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 之间的数值。
animation-delay:动画效果延迟时间
animation-delay:time;
time 秒或毫秒
animation-iteration-count: 动画执行次数
animation-iteration-count: n|infinite;
n 具体的次数
infinite 无限重复
animation-direction:动画执行方向
animation-direction: normal|alternate;
normal 正常顺序(默认值)
alternate 动画轮流反向播放
animation-play-state:动画执行状态
animation-play-state: paused|running;
paused 暂停动画
running 运行动画
animation-fill-mode:动画执行过程效果是否可见
animation-fill-mode : none | forwards | backwards | both;
none 不改变(默认值)
forwards 当动画完成后,保持最后一个属性值(在最后一个关键帧中定义)
backwards 在 animation-delay 所指定的一段时间内,在动画显示之前,应用开始属性值(在第一个关键帧中定义)
both 向前和向后填充模式都被应用
@keyframes:规定动画
@keyframes animationname {keyframes-selector {css-styles;}}
animationname 定义动画的名称。
keyframes-selector 动画时长的百分比。
0-100%
0-100%
from(与 0% 相同)
to(与 100% 相同)
可以只有to
css-styles 一个或多个合法的 CSS 样式属性。
CSS3过渡与动画的异同
动画事件:
动画开始:
obj.addEventListener("webkitAnimationStart", fn);
obj.addEventListener("animationstart", fn);
动画执行过程中触发:
obj.addEventListener("webkitAnimationIteration", fn);
obj.addEventListener("animationiteration", fn);
动画结束是触发:
obj.addEventListener('webkitAnimationEnd',fn);
obj.addEventListener('animationend',fn);