reading-notes

Read: 14a - CSS Transforms, Transitions, and Animations

CSS Transforms

The transform property applies a 2D or 3D transformation to an element. This property allows you to rotate, scale, move, skew, etc., elements.

CSS transform

2D Transforms 2D Rotate

2D Scale

2D Translate

Transform Origin

The transform-origin property allows you to change the position of transformed elements. 2D transformations can change the x- and y-axis of an element. 3D transformations can also change the z-axis of an element.

Perspective

The perspective property is used to give a 3D-positioned element some perspective. The perspective property defines how far the object is away from the user. So, a lower value will result in a more intensive 3D effect than a higher value.

3D Transforms

3D Rotate

3D Scale * transform: perspective(200px) scaleZ(1.75) rotateX(45deg);

3D Translate * transform: perspective(200px) translateZ(-50px);

Transform Style

The transform-style property specifies how nested elements are rendered in 3D space. Note: This property must be used together with the transform property.

Transitions and Animations

CSS Transitions: CSS transitions allows you to change property values smoothly, over a given duration.

How to Use CSS Transitions? To create a transition effect, you must specify two things:

Note: If the duration part is not specified, the transition will have no effect, because the default value is 0.

CSS transition

Change Several Property Values The following example adds a transition effect for both the width and height property, with a duration of 2 seconds for the width and 4 seconds for the height:

Specify the Speed Curve of the Transition The transition-timing-function property specifies the speed curve of the transition effect. The transition-timing-function property can have the following values:

Delay the Transition Effect The transition-delay property specifies a delay (in seconds) for the transition effect. The following example has a 1 second delay before starting:

Animation

CSS allows animation of HTML elements without using JavaScript or Flash!

CSS animation

CSS Animations An animation lets an element gradually change from one style to another. You can change as many CSS properties you want, as many times you want. To use CSS animation, you must first specify some keyframes for the animation. Keyframes hold what styles the element will have at certain times.

Animation properties

8 simple CSS3 transitions that will wow your users