a
CSS3 transforms allow you to translate, rotate, scale, and skew elements.
translate() | rotate() |
scale() | skewX() |
skewY() | matrix() |
translate()
The translate()
method moves an element from its current
position (according to the parameters given for the X-axis and the Y-axis).
-webkit-transform: translate(50px, 100px);
-ms-transform: translate(50px, 100px);
transform: translate(50px, 100px);
CSS
rotate()
The rotate()
method rotates an element clockwise or
counter-clockwise according to a given degree.
-ms-transform: rotate(20deg);
-webkit-transform: rotate(20deg);
transform: rotate(20deg);
CSS
scale()
The scale()
method increases or decreases the size of an
element (according to the parameters given for the width and height).
-ms-transform: scale(2, 3);
-webkit-transform: scale(2, 3);
transform: scale(2, 3);
CSS
Skew()
The skew()
method skews an element
along the X and Y-axis by the given angles.
-ms-transform: skew(20deg, 10deg);
-webkit-transform: skew(20deg, 10deg);
transform: skew(20deg, 10deg);
CSS
matrix()
The matrix()
method combines all
the 2D transform methods into one.
The parameters are as follow:
matrix(scaleX(),skewY(),skewX(),scaleY(),translateX(),translateY());
-ms-transform: matrix(1, -0.3, 0, 1, 0, 0);
-webkit-transform: matrix(1, -0.3, 0, 1, 0, 0);
transform: matrix(1, -0.3, 0, 1, 0, 0);
CSS
rotateX() |
rotateY() |
rotateZ() |
rotateX()
The rotateX()
method rotates an element
around its X-axis at a given degree:
-webkit-transform: rotateX(150deg);
transform: rotateX(150deg);
CSS
rotateY()
The rotateY()
method rotates an element
around its y-axis at a given degree:
-webkit-transform: rotateY(150deg);
transform: rotateY(150deg);
CSS
rotateZ()
The rotateZ()
method rotates an element
around its y-axis at a given degree:
-webkit-transform: rotateY(150deg);
transform: rotateY(150deg);
CSS
translate3D(x,y,z)
The translate3D
method defines a 3D translation.
-webkit-transform: rotateY(150deg);
transform: rotateY(150deg);
CSS
CSS3 transitions allows you to change property values smoothly (from one value to another), over a given duration.
To create a transition effect, you must specify two things:
div {
width: 20px;
height: 30px;
-webkit-transition: width 2s, height 4s;
transition: width 2s, height 4s;
}
div:hover {
width: 200px;
height: 300px;
}
CSS
The transition-timing-function
property specifies
the speed curve of the transition effect.
ease | linear |
ease-in | ease-out |
ease-in-out | cubic-bezier(n,n,n,n) |
#div1 {transition-timing-function: linear;}
#div2 {transition-timing-function: ease;}
#div3 {transition-timing-function: ease-in;}
#div4 {transition-timing-function: ease-out;}
#div5 {transition-timing-function: ease-in-out;}
CSS
The transition-delay
property specifies a delay
(in seconds) for the transition effect.
-webkit-transition-delay: 1s;
transition-delay: 1s;
CSS
Best thing to happen to the mankind. Period.
CSS3 animations allows animation of most HTML elements without using JavaScript or Flash!
To use CSS3 animation, you must first specify
some keyframes for the animation.
Keyframes hold what styles the element will have at
certain times.
animation-name
and animation-duration
We need to give our animation a name to refer to it later from
the keyframe rule.
We also need to specify the animation-duration
property,
else the animation won't have any effect because it's default value is 0.
When you specify CSS styles inside the @keyframes rule, the animation will gradually change from the current style to the new style at certain times.
@keyframes example {
from {background-color: red;}
to {background-color: yellow;}
}
div {
background-color: red;
animation-name: example;
animation-duration: 4s;
}
CSS
Apart from keywords, we can also use "%" and use numbers from 0(start) to 100(complete).
@keyframes example {
0% {background-color: red;}
25% {background-color: yellow;}
50% {background-color: blue;}
100% {background-color: green;}
}
div {
width: 100px;
height: 100px;
background-color: red;
animation-name: example;
animation-duration: 4s;
}
CSS
animation-delay
The animation-delay property specifies a delay for the start of an animation.
animation-iteration-count
The animation-iteration-count property specifies the number of times an animation should run.
animation-direction
The animation-direction property is used to let an animation run in reverse direction or alternate cycles.
div {
width: 100px;
height: 100px;
background-color: red;
animation-name: example;
animation-duration: 4s;
animation-iteration-count: 3;
animation-direction: alternate;
}
The animation-timing-function
property specifies
the speed curve of the transition effect.
ease | linear |
ease-in | ease-out |
ease-in-out | cubic-bezier(n,n,n,n) |