Home >Web Front-end >HTML Tutorial >CSS3 learning animation property_html/css_WEB-ITnose
I found the new attribute of animation very interesting, learn it here and organize it!
Browser support :
Internet Explorer 10, Firefox and Opera support the animation attribute;
Safari and Chrome support the alternative -webkit-animation attribute .
Definition and Usage
The animation property is a shorthand property for setting six animation properties:
Syntax
animation: name duration timing-function delay iteration-count direction;
animation-name | Specifies the keyframe that needs to be bound to the selector name. .
| ||||||||||||
animation-duration | Specifies the time it takes to complete the animation, in seconds or milliseconds.
| ||||||||||||
animation-timing-function | Specifies the speed curve of animation. | ||||||||||||
animation-delay | Specifies the delay before the animation starts.
| ||||||||||||
animation-iteration-count | Specifies the number of times the animation should be played. | ||||||||||||
animation-direction | Specifies whether the animation should be played in reverse in turn.
|
linear | 动画从头到尾的速度是相同的。 |
ease | 默认。动画以低速开始,然后加快,在结束前变慢。 |
ease-in | 动画以低速开始。 |
ease-out | 动画以低速结束。 |
ease-in-out | 动画以低速开始和结束。 |
cubic-bezier(n,n,n,n) | 在 cubic-bezier 函数中自己的值。可能的值是从 0 到 1 的数值。 |
Where
animation-timing-function uses a mathematical function called the Cubic Bezier function to generate the velocity curve. You can use your own values in this function, or predefined values:
Case:
Very practical, an arrow jumps up and down in a loop
#auto{
-webkit-animation:dd 1s infinite;
animation:dd 1s infinite;
}
@keyframes dd{
50% {transform:translate(0, 0)}
100% {transform:translate(0, 10px)}}
@-webkit-keyframes dd{0% {-webkit-transform:translate(0, 10px)}
50% {-webkit-transform:translate(0, 0)}100% {-webkit-transform:translate(0, 10px)}
} Note: The animation attribute must be used in conjunction with @keyframes The percentage means the percentage of duration. If duration is not set, it means is infinity. transform:translate(): Meaning - change, displacement; also a new attribute in CSS3.