Talking about animation effects. CSS animation is a powerful tool for Mobilweb development, and CSS animation must be discussed. Due to issues such as Mobil device capabilities, most animation implementation plans on PC are not feasible on Mobil. Fortunately, I can use CSS animation on Mobil. Today I will take a look at the three main members of CSS animation.
CSS change (Transit
The default mutation animation of transit. When the CSS properties are changed, define the CSS properties that need to be changed. The transit animation is triggered. But not all CSS property changes will trigger translat. There is no official document that lists those that are possible and those that are not, but you can use some tips to identify them. For example, those values are continuous numeric characteristics. For example, width, height, top, left, color, opac are all possible, but visibl is not possible, even though its value is a numeric type. But it is not continuous
and has high performance. It can be run on transitiphon and Android platforms.
It can also be defined through JavaScript. It is very easy to use. 🎜>
1. Define the transit characteristics of the Dom element (duratdelaitimefunction, etc.) 2. Use JavaScript to change the CSS style of the Dom element
How to, 1. Define the transit characteristics of the Dom element (duratdelaitimefunction, etc.) 2 .Use JavaScript to change the CSS style of the Dom element
-webkit-transition-properti defines the characteristics of the required mutation-webkit-transition-dur defines the animation time-webkit-transition-delai defines the delay time-webkit-transition-timing-funct definition Bezier curve function
-webkit-transition-properti can define specific characteristics, -webkit-transition-properti defines the characteristics that require mutation -webkit-transition-dur defines animation time -webkit-transition -delai defines delay time -webkit-transition-timing-funct defines Bezier curve function
<-webkit-transition-properti can define specific characteristics that require mutation. Features - webkit-transition-dur defines animation time - webkit-transition-delai defines delay time - webkit-transition-timing-funct defines Bezier curve function < - webkit-transition-properti can define specific characteristics . For example, multiple properties of widthheight are separated by commas. You can also define all so that all style property changes with continuous numerical types will trigger transition. Now you can try to create a transit
div.zoom-fad{-webkit-transition-property: -webkit-transform,div.zoom-fad{-webkit-transition-property:-webkit-transform,div.zoom-fad{-webkit-transition-property:-webkit-transform,opacity;-webkit-transition-duration: 4s,2s;-webkit-transition-delay:2s,0;}
You can also write these characteristics in one line,
div.slid{-webkit- transition:opac500mease-out100ms;}
-webkit-transition-timing-funct can define the mutation speed curve of the animation, div.slid{-webkit-transition:opac500mease-out100ms;}
<- webkit-transition-timing-funct can define the mutation speed curve of animation. div.slid{-webkit-transition:opac500mease-out100ms;}<-webkit-transition-timing-funct can define the mutation speed curve of the animation. It can be set to,
gradually slow down, and the Bezier curve function is cubic-bezi0.25, eas is the default. -webkit-transition-timing-funct can also set the short name. 0.1,0.25,1.0linear average speed, Bezier curve function is cubic-bezi0.0,0.0,1.0,1.0ease-in accelerates, Bezier curve function is cubic-bezi0.42,0,1.0, 1.0ease-out slows down when fading out. The Bezier curve function is cubic-bezi0,0,0.58,1.0ease-in-out speeds up and then slows down. The Bezier curve function is cubic-bezi0.42,0,0.58,1.0
You can also directly set your own defined Bezier curve function
The webkitTransitionEnd event will be triggered after the transition is completed. You can use addEventListen to add event listeners.
element.addEventListen'webkitTransitionEnd',element.addEventListen'webkitTransitionEnd',element.addEventListen'webkitTransitionEnd',functionevent{alert"Finishtransition";};
A nimat
A nimat
A nimat
A nimat
transit is very simple and convenient to use, but if you want to control the changes of each frame yourself, then transit is not satisfactory. At this time, you need to use animanim with the following features,
-webkit-animation-nam specifies the keyframe name (the name of the animation) -webkit-animation-dur specifies the number of seconds or milliseconds to complete the animation-webkit -animation-timing-funct specifies the speed curve of the animation -webkit-animation-delai delays the start of animation -webkit-animation-iteration-count playback times; default: 1 can be defined as infinite) -webkit-animation-direct animation direction; Default: normal
Anim, which is different from transit, needs to define frames. -webkit-animation-nam specifies the key frame name (the name of the animation) -webkit-animation-dur specifies the number of seconds or milliseconds to complete the animation -webkit-animation- timing-funct specifies the speed curve of the animation -webkit-animation-delai delays the start of animation -webkit-animation-iteration-count playback times; default: 1 can be defined as infinite) -webkit-animation-direct animation direction; default: normal
@-webkit-keyframsquarePath{from{top:100px;left:100px;}to{top:0px;left:0px;} use from represents the starting frame, @-webkit-keyframsquarePath{from{top:100px;left:100px;}to{top:0px;left:0px;}