a { color: green; } a:hover { color: orange; }
Hover Over Me
a { color: green; transition: 1s; } a:hover { color: orange; }
Hover Over Me
Enables the transition of properties from one state to the next over a defined length of time
code { color: black; font-size: 85%; background-color: rgba(255,255,255,0.9); transition: all 2s ease-in 50ms; } code:hover { color: red; font-size: 120%; background-color: rgba(255,255,255,0.8); }
code { transition: color, font-size, background-color 2s ease-in 50ms; }
code { color: black; font-size: 85%; background-color: rgba(255,255,255,0.9); transition: all 2s ease-in 50ms; } code:hover { color: red; transform: scale(1.4); transform-origin: 0 0; background-color: rgba(255,255,255,0.8); }
code { transition: transform 2s ease-in 50ms; }
Anything that has intermediate values
code { opacity: 1; } code:halfway { opacity: 0.5; } code:hover { opacity: 0; }
code { display: block; } code:halfway { display: ??? } code:hover { display: none; }
2 values that have REAL intermediary values
code { font-size: 100%; } code:halfway { font-size: 110%; } code:hover { font-size: 120%; }
code { height: auto; } code:halfway { height: ??? } code:hover { height: 1000px; }
transitionend
eventtransitionend
for EVERY propertytransitionend
for each long-hand property within a shorthandtable { border: 1px black solid; transition: border 1s linear 50ms; } table:hover { border: 5px red solid; }
nav ul li { list-style-type: none; } nav > ul > li { display: inline-block; position:relative; } nav ul ul { transform: scale(1,0); transform-origin: top center; transition:0.2s linear 50ms; position:absolute; top: 100%; } nav li:hover ul { transform: scale(1,1); }
|
|
|
|
|
10 |
Prefix -webkit- for < iOS9 / Safari 9 and Android <= 4.4.4.
@keyframes ... @-webkit-keyframes ....
@keyframes clever_name_here ... @-webkit-keyframes clever_name_here ...
Don't use keyterms!
@keyframes slides { } @-webkit-keyframes slides { }
@keyframes writing { from { left: 0; } to { left: 100%; } }
@keyframes writing { 0% { left: 0; } 100% { left: 100%; } }
Don't forget the %
Don't quote the animation name
@keyframes writingWhileTired { 0% { left: 0; } 10% { left: 45%; } 90% { left: 55%; } 100% { left: 100%; } }
@keyframes W { 0% { left: 0; top: 0; } 25%, 75% { top: 400px; } 50% { top: 50px; } 100% { left: 80%; top: 0; } }
.pencil { width:100px; text-align: right; border-bottom: 10px solid; } .pencil::after { content: '✎'; position: absolute; bottom: -20px; right: -10px; }
@keyframes drawALine { 0%{ width:0; color:green; } 100% { width: 100%; color:blue; } }
.pencil {
animation-name: drawALine;
animation-duration: 3s;
}
.pencil {
animation-name: drawALine;
animation-duration: 5s;
animation-timing-function: ease-in-out;
}
ease linear ease-in ease-out ease-in-out cubic-bezier(x1, y1, x2, y2) step-start /* same as steps(1, start) */ step-end /* same as steps(1, end) */ steps( X, start|end) /* X = # of steps + when change of value occurs */
.pencil { ... animation-name: drawALine; animation-duration: 3s; animation-timing-function: ease-in-out; animation-iteration-count: 3; }
‘infinite’ or number. Default is ‘1’.
-webkit-animation-iteration-count: 3;
.pencil {
animation-name: drawALine;
animation-duration: 8s;
animation-timing-function: ease-in-out;
animation-iteration-count: 2;
animation-delay: 2s;
}
.pencil {
...
animation-name: drawALine;
animation-duration: 5s;
animation-timing-function: ease-in-out;
animation-iteration-count: 5;
animation-direction: normal
}
values: normal | alternate | reverse | alternate-reverse;
animation-direction: alternate;
.pencil { animation-name: drawALine; animation-duration: 5s; animation-delay: 100ms; animation-timing-function: ease-in-out; animation-iteration-count: 5;animation-direction: normal;}
. . . can also be written as . . .
.pencil { animation: drawALine 5s ease-in-out 100ms 5; }
values: none | forwards | backwards | both
.pencil {
animation-name: gettingThePencil;
animation-duration: 3s;
animation-timing-function: ease-in-out;
animation-iteration-count: 1;
animation-delay: 2s;
animation-fill-mode: none;
}
.pencil { animation: gettingThePencil 3s ease-in-out 1s forwards; }
.box { animation: showme 5s linear 5s 1;} @keyframes showme { 0% {left: 200px; background-color:blue;} 50% {background-color:green;} 100% {left: 600px; background-color: yellow;} }
animation-play-state: paused | running
.pencil { transform-origin: center 300px; animation: writingInCircles 3s linear infinite; } .pencil:hover { animation-play-state:paused; }
@keyframes writingInCircles { 100% { transform: rotate(360deg); } }
animation-play-state: paused | running
.pencil:hover { animation-play-state: paused; }
el.addEventListener( 'animationend', function( event ) { console.log('Animation Ended'); }, false );
el.addEventListener( 'animationend', function( event ) { el.removeClassName('newClass'); setTimeout("el.addClassName('newClass')", 100ms) }, false );
webkitAnimationEnd animationend
#DiveAnim 5 Sooooo much cowbell