Some examples here
Transitions: when a certain CSS property change, the change won’t happen abruptly, but overtime:
#box {
transition-property: opacity, left;
transition-duration: 3s, 5s;
}
So when element #box experience a change in opacity or left, the change will take 3 and 5 seconds respectively.
Here’s an example of all the transition properties:
#content a {
…(more styles)…
transition-property: all;
transition-duration: 1s;
transition-timing-function: ease;
transition-delay: 0s;
}
Or combined in just one line:
#content a {
/*…existing styles…*/
transition: all 1s ease 0s;
}
Example with the current vendor prefixes:
-o-transition: all 1s ease 0s;
-ms-transition: all 1s ease 0s;
-moz-transition: all 1s ease 0s;
-webkit-transition: all 1s ease 0s;
transition: all 1s ease 0s;
You can define different transition times for different properties:
#content a {
…(more styles)…
transition-property: border, color, text-shadow;
transition-duration: 2s, 3s, 8s;
}
According to the spec, these are the CSS properties you can apply transitions to:
http://www.w3.org/TR/css3-transitions/#properties-from-css-
Animations don’t passively wait for properties to change (as transitions do), they are explicitly triggered by, say, adding the right class to a DOM object, for example:
.warning {
animation-name: ‘horizontal-slide’;
animation-duration: 5s;
animation-iteration-count: 10;
}
@keyframes ‘horizontal-slide’ {
from {
left: 0;
}
to {
left: 100px;
}
}
Example of @-webkit-keyframes
When .warning is applied to an element in the DOM, we get the animation working, specified by the keyframes, and with a certain duration and number of iterations.
With 2D transformations, you can scale, rotate and move point of origin on elements, based on CSS settings:
#box.move-me {
height: 100px; width: 100px;
transform: translate(50px, 50px) scale(1.5, 1.5) rotate(90deg);
}
The foregoing example moves #box by 50 pixels in both the X and Y directions, scales the element by
150%, and then rotates it 90 degrees clockwise about the z axis.
Here’s the breakdown of the particular properties:
transform: scale(1.7); /* size the object 170% of its current size */
transform: translate(40px, 0px); /* Move the object 40px horizontally, and 0 vertically, settings can be negative values, or percentages */
transform: rotate(3600deg); /* Make elements rotate, big values will make elements spin as they land in their current setting */
transform: skew(10deg, 2deg); /* Same skew as photoshop, if only one value provided, it will apply for both: x and y axes */
transform: matrix(1.678, -0.256, 1.522, 2.333, -51.533, -1.989); /* Combine all the above, in one line */
transform-origin: 20% 20%; /* move the current center of the object 20% horizontally, and 20% vertically */