You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1.6 KiB
1.6 KiB
CSS - Transform
Lesson Objectives
- Use the CSS3 transform property to visually manipulate DOM elements in a 2D space
- Use the CSS3 transform property to visually manipulate DOM elements in a 3D space
- Explain why using transform for animation is better than using position
Use the CSS3 transform property to visually manipulate DOM elements in a 2D space
- transform:rotate(10deg);
- transform:scale(1.1);
- transform:translateX(10px);
- transform:skewX(45deg);
You can perform multiple transforms in one statement
- transform: scale(2) skewY(0.3) rotate(4deg);
Use the CSS3 transform property to visually manipulate DOM elements in a 3D space
The Z axis extends out of the screen
- rotateX();
- rotateY();
- rotateZ();
- translateX();
- translateY();
- translateZ();
- scaleX();
- scaleY();
- scaleZ();
If you know the math, you can write your own transformation matrix - This is how transformations work behind the scenes
- matrix(n,n,n,n,n,n)
- matrix3d(n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n)
- http://periodic.famo.us/
Explain why using transform for animation is better than using position
- http://codepen.io/paulirish/pen/nkwKs
- top/left
- http://codepen.io/paulirish/pen/LsxyF
- translate
Transforms are better for animation for two reasons
- When elements are changed in the DOM, the browser checks to see if other elements are being pushed around. When using transforms, the browser doesn't do this.
- If you're doing a 3D transform, the computer's GPU is engaged, which is really fast
Example: transition: transform 1s ease-in-out;