CSS3 Transforms Transitions and Animations
FEVR 25.9.2014
The Fab
Slide 2
Slide 2 text
Transform
The transform property applies a 2D or 3D transformation to an
element. This property allows you to rotate, scale, move, skew,
etc., elements.
Transform origin
the default transform origin is the dead center of an element,
both 50% horizontally and 50% vertically.
.square {
transform: rotate(45deg);
transform-origin: right top;
}
.square {
transform: rotate(45deg);
transform-origin: 100% 100%;
}
Slide 8
Slide 8 text
Transform 3D
transform: translateZ(0);
transform: translate3d(0,0,0);
3d transform uses GPU not CPU, so they are faster than 2d
transform
Slide 9
Slide 9 text
Transition
CSS Transition allows property changes in CSS values to occur
smoothly over a specified duration
Slide 10
Slide 10 text
Anatomy of a Transition
Keyframe 1
Keyframe 2
TWEEN
Slide 11
Slide 11 text
Transition properties
.square {
//name of the CSS property the transition effect is for
transition-property: width;
//how many seconds or milliseconds a transition effect takes to complete
transition-duration: 1s;
//the speed curve of the transition effect
transition-timing-function: linear;
//when the transition effect will start
transition-delay: 2s;
}
.square {
transition: width 1s linear 2s;
}
Slide 12
Slide 12 text
Transition timing function
LINEAR
same speed from start
to end
EASE IN-OUT
slow start and end
EASE OUT
slow end
EASE IN
slow start
Animation
CSS Animation is like transitions, however we can specify the
number of times it plays and whether it plays in a single direction
or both directions
They are named and can be reusable by more than one css rule
Animation Values
animation: ‘moveit’ 4s ease 3 normal;
animation-name: ‘moveit’
animation-duration: time
animation-timing-function: linear/ease/ease-in/ease-out/ease-in-out
animation-iteration-count: number or infinite
animation-direction: normal or alternate
animation-delay: time
animation-fill-mode: backwards/forwards/none/both
//Configures what values are applied by the animation before and after it is executing.