Css notes -- differentiate transform transition animation and css3transform in css3

Source: Internet
Author: User

Css notes -- differentiate transform transition animation and css3transform in css3
Source: animation-related attributes in http://blog.csdn.net/dyllove98/article/details/8957232 CSS3 have three transform, transition, and animation attributes. Here is a one-to-one explanation: Transform Literally, the definition of transform is changed to make... Deformation; conversion. Here we can understand it as deformation. How can it be changed? None indicates that the rotation is not performed. rotate rotation transform: rotate (20deg) can be negative. The base point of the transform-origin-defined rotation can be left top center right bottom or coordinate value (50px 70px ). Skew twist transform: skew (30deg, 30deg) skew (tilt relative to the X axis, tilt relative to the Y axis) scale transform: scale (2, 3) scale 2 times horizontal, vertical zoom 3 times. For example, you can add a parameter to proportional amplification. Translate mobile transform: translate (50px, 50px); matrix deformation basic syntax: transform: matrix (a, c, B, d, tx, ty); where a, c, B, d is a two-dimensional matrix:

 

   ┌     ┐    │ a b │   │ c d │   └     ┘
A: X axis zoom ratio B: Y axis tilt c: Y axis zoom ratio d: X axis tilt
Tx and ty are the elements that are located based on the X and Y coordinates. Actually, it is translate (tx, ty)



Transition

The transition of CSS3 in W3C standards is described as follows: "The transition of CSS allows the attribute value of CSS to smoothly transition within a certain period of time. This effect can be triggered by mouse clicking, getting focus, being clicked, or changing any element, and the CSS attribute values can be smoothly changed with the animation effect.
Transition mainly includes four attribute values: transition-property: the attribute for performing the transformation;
Transition-duration: transition duration:
Transition-timing-function: the rate change during the duration of the transition;
Transition-delay: Change the delay time
The following describes the four attributes:
transition-property

Syntax:

Transition-property: none | all | [<IDENT>]

Transition-property is used to specify the effect of transition when one of the element's attributes changes. It has the following values: none (no conversion); all (all attributes changed) this is also the default value; indent (element attribute name); when its value is none, transition immediately stops execution. When it is specified as all, if the element produces any changes to the attribute value, the transition effect is executed. The ident is a property value that can be specified for an element. The corresponding types are as follows:

1. color: The color is transformed by the red, green, blue, and transparency components (each value is processed separately), such as background-color, border-color, color, and outline-color CSS attributes;

2. length: real numbers, such as word-spacing, width, vertical-align, top, right, bottom, left, padding, outline-width, margin, min-width, min-height, max-width, max-height, line-height, height, border-width, border-spacing, background-position, and other attributes;

3. percentage: real numbers, such as word-spacing, width, vertical-align, top, right, bottom, left, min-width, min-height, max-width, max-height, line-height, height, background-position, and other attributes;

4. The integer discrete step (the entire number) occurs in the real numeric space and when floor () is used to convert it to an integer, such as outline-offset and z-index;

5. Real (float type) values of a number, such as zoom, opacity, and font-weight;

6. transform list: For details, see CSS3 Transform.

7. rectangle: converts values by x, y, width, and height, for example, crop;

8. visibility: discrete step. In the range of 0 to 1, 0 indicates "hidden", and 1 indicates full "display", for example, visibility;

9. shadow: applies to color, x, y, and blur attributes, such as text-shadow;

10. gradient: changes the position and color of each stop. They must have the same type (radial or linear) and the same stop value for animation, such as background-image;

11. paint server (SVG): Only the following conditions are supported: From gradient to gradient and from color to color, and then the work is similar to the above;

12. space-separated list of above: if the list has the same project value, each item in the list changes according to the preceding rules; otherwise, no changes are made;

13. a shorthand property: If all part of the abbreviation can be animated, it will change like all single attribute changes.

Attributes that support performing the transition effect:

Property Name Type
Background-color As color
Background-position As repeatable list of simple list of length, percentage, or calc
Border-bottom-color As color
Border-bottom-width As length
Border-left-color As color
Border-left-width As length
Border-right-color As color
Border-right-width As length
Border-spacing As simple list of length
Border-top-color As color
Border-top-width As length
Bottom As length, percentage, or calc
Clip As rectangle
Color As color
Font-size As length
Font-weight As font weight
Height As length, percentage, or calc
Left As length, percentage, or calc
Letter-spacing As length
Line-height As either number or length
Margin-bottom As length
Margin-left As length
Margin-right As length
Margin-top As length
Max-height As length, percentage, or calc
Max-width As length, percentage, or calc
Min-height As length, percentage, or calc
Min-width As length, percentage, or calc
Opacity As number
Outline-color As color
Outline-width As length
Padding-bottom As length
Padding-left As length
Padding-right As length
Padding-top As length
Right As length, percentage, or calc
Text-indent As length, percentage, or calc
Text-shadow As shadow list
Top As length, percentage, or calc
Vertical-align As length
Visibility As visibility
Width As length, percentage, or calc
Word-spacing As length
Z-index As integer
 

 

Transition-durationtransition-duration is used to specify the duration of the element conversion process. The value <time> is a numerical value and the unit is s (seconds). It can act on all elements, including before and: after pseudo element. The default value is 0, that is, it is real-time during transformation. Transition-timing-function

Valid value:

The value of transition-timing-function allows you to change the conversion rate of the attribute value based on time. transition-timing-function has six possible values:

1. Slow: (gradually slowing down) default value. The Lag Function is equivalent to the besell curve (0.25, 0.1, 0.25, 1.0 );

2. linear: (uniform speed). The linear function is equivalent to the besell curve (0.0, 0.0, 1.0, 1.0 );

3. Inflow-in: (acceleration). The inflow-in function is equivalent to the besell curve (0.42, 0, 1.0, 1.0 );

4. Forward-out: (slowing down). The forward-out function is equivalent to the besell curve (0, 0, 0.58, 1.0 );

5. Slow-in-out: (acceleration and then deceleration). The slow-in-out function is equivalent to the besell curve (0.42, 0, 0.58, 1.0 );

6. cubic-besuppliers: (this value allows you to customize a time curve.) The specific cubic-besuppliers curve. (X1, y1, x2, y2) four values are specific to the Point P1 and point P2 on the curve. All values must be in the [0, 1] region; otherwise, they are invalid.

The value of the attribute value in the "Conversion" process is calculated by using the béserx curve, as shown in the following curve, by changing P1 (x1, y1) and P2 (x2, y2) can change the Output Percentage of the entire process. The default value is default.

Transition-delay

Transition-delay is used to specify the time when an animation starts to be executed, that is, how long after the element attribute value is changed to start performing the transition effect. The value <time> is a numerical value, the Unit is s (seconds). It is similar to transition-duration and can also act on all elements, including: before AND: after pseudo elements. The default size is "0", that is, the conversion is executed immediately without delay.

Sometimes we want to change the transition effect of two or more CSS attributes, instead of changing the attribute of the CSS effect. We only need to concatenate several transition declarations and use commas (, "), and each of them can have their own different continuation time and their time rate conversion methods. However, it is worth noting that the values of transition-delay and transition-duration are both time values. Therefore, to distinguish the locations of these values in the write link, the browser generally determines the order of order, the first value can be resolved to the duration value of time as transition-duration, and the second value as transition-delay. For example:

A {transition: background 0.5 s audio-in, color 0.3 s audio-out}

If you want to perform all the attributes of the transition effect on the element, you can also use the all attribute value for the operation. At this time, they share the same duration and rate conversion method, for example:

A {transition: all 0.5 s transfer-in}

}

 

Animation

The name implies the meaning of an animation. The Animation is applied to the page DOM to produce Animation effects. Before introducing Animation, we need to first understand a special thing, that is, "Keyframes". We call it "Key Frame ", friends who have played flash may be familiar with this thing.

Example of a Website:

@-webkit-keyframes 'wobble' {     0% {        margin-left: 100px;        background: green;     }     40% {        margin-left: 150px;        background: orange;     }     60% {        margin-left: 75px;        background: blue;     }     100% {        margin-left: 100px;        background: red;     }  }

  

Here we define an animation named "wobble", with any name. In several stages, 0% 40% 60% is used for the transition.

After keyframes is defined, you can call the defined Animation "wobble.

Next, let's see how to call the animation attribute for an element.

. Demo1 {width: 50px; height: 50px; margin-left: 100px; background: blue;-webkit-animation-name: 'wobble ';/* animation attribute name, that is, the animation name defined by keyframes */-webkit-animation-duration: 10 s;/* animation duration */-webkit-animation-timing-function: animation-in-out;/* animation frequency, which is the same as transition-timing-function */-webkit-animation-delay: 2 s; /* animation delay time */-webkit-animation-iteration-count: 10;/* define cyclic data. infinite is infinite times */-webkit-animation-direction: alternate; /* define the Animation Mode */}
 
animation-name:
Animation-name: it is used to define the name of an animation, which is the name in Keyframes. Otherwise, there will be no animation effect. None is the default value. If the value is none, there will be no animation effect. In addition, this attribute is the same as the preceding transition. We can attach several animations to an element. We only need to separate them with commas.

The animation of CSS3 is similar to the transition attribute. They all change the element's attribute values over time. The main difference between them is that transition needs to trigger an event (hover event or click event) to change its css attributes over time; however, animation can explicitly change the attribute value of element css over time without triggering any event to achieve an animation effect. In this way, we can directly call the animation attribute of animation in an element. Based on this, the animation attribute value of css3 needs to be clearly defined, which is returned to what we mentioned above, we need keyframes to define css attribute values of different time periods to achieve the effect of element changes in different time periods.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.