内容 Content
- Lorem ipsum dolor sit.
- Aperiam beatae odit consectetur?
- Consectetur amet repellat error?
- Cum, delectus deserunt? Magni.
- Atque illum reiciendis ut.
transition: property duration timing-function delay;
transition-property: transition-duration: transition-timing-function: transition-delay:
item | desc |
---|---|
property | 元素参与过渡的属性,必须是 数值型 的属性
通常指定为 all;建议 指定为特定属性 |
duration | 过渡持续时间,单位秒 s 或毫秒 ms,必选参数,且必须是第一个时间参数;第二个时间参数是延迟时间
UI界面的过渡通常不超过 0.4s |
timing-function | 时间函数,过渡的效果/方式
默认是 ease |
delay | 过渡延迟时间,必须是第二个时间参数;第一个时间参数是过渡时间 |
item | desc |
---|---|
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 函数中定义自己的值 |
steps() | 步进方式变换,见后续内容 |
steps(number_of_steps,direction)
@keyframes ani_name { from { /* 开始状态/第一个关键帧 */ } to { /* 结束状态/最后一个关键帧 */ } }
@keyframes ani_name { 0% { /* 开始状态/第一个关键帧 */ } 50% { /* 中间状态/中间关键帧 */ } 100% { /* 结束状态/最后一个关键帧 */ } }
animation: name duration timing-function delay iteration-count direction fill-mode;
animation-name: animation-duration: animation-timing-function: animation-delay: animation-iteration-count: animation-direction: animation-fill-mode:
item | desc |
---|---|
name | 动画名称 |
duration | 动画持续时间 - length of time that an animation takes to complete one cycle
单位秒 s 或毫秒 ms 必须是正值或0 - must be positive or zero 必须指定单位 - unit is required |
timing-function | 动画方式;见下表 |
delay | 动画延迟时间,必须是第2个时间参数
正值 positive value:推迟 负值 negative value:提前 |
iteration-count | 动画播放次数
数值:默认1 infinite:无穷;重复播放 |
direction | 动画方向
alternate: reverse:反向播放 alternate-reverse:先反向播放,再正向播放 |
fill-mode | 动画开始和结束时如何应用状态/样式 - applies styles to its target before and after its execution
none:不指定任何样式;从元素初始状态开始,结束后返回初始状态;默认值 backwards:动画开始时,从第一个关键帧开始;如果有延迟,将始终保持在当前状态 forwards:动画结束时,保持在最后一个关键帧 - retain the computed values set by the last keyframe;特别适合多个有延迟的动画 both:从第一个关键帧开始,结束时保持在最后一个关键帧;不会返回初始状态 |
animation-play-state | 动画状态 - whether an animation is running or paused
paused:暂停状态 - currently paused running:播放状态 - currently playing 可以通过 :hover 或 JavaScript 来控制动画的播放状态 |
animation-timeline | 动画时间线 |
item | desc |
---|---|
ease | 默认。动画以低速开始,然后加快,在结束前变慢 |
linear | 动画从头到尾的速度是相同的 |
ease-in | 动画以低速开始 |
ease-out | 动画以低速结束 |
ease-in-out | 动画以低速开始和结束 |
cubic-bezier(n,n,n,n) | 使用 cubic-bezier 函数定义过程 |
steps() | 步进动画方式;见后续内容 |
steps(number_of_steps,direction)
item | desc |
---|---|
animation-timeline | none | auto | scroll() | view() |
animation-range-start | 动画开始范围;默认 0 |
animation-range-end | 动画结束范围;默认 100% |
animation-range | 复合属性;动画范围;默认 0 100% |