Ok, I need to write down transitions code and its important points for my own use, sorry, everybody already knows 🙂 But need it to be written down here.
So CSS transition typically consist of transition: [CSS property or all] [transition-duration] [transition-timing-effect] [transition-delay];
. But all
, effect and delay could be omitted.
-webkit-transition: all 500ms ease 0.1s; -moz-transition: all 500ms ease 0.1s; -o-transition: all 500ms ease 0.1s; transition: all 500ms ease 0.1s;
No need to use -ms-
for transition, they are supported prefixed, but only starting from IE10.
Timing could be in seconds too, like 1s
, but don’t use just 0
without units.
Transition properties (elements to which transition applies) could go in line separated by comma, like background-color, opacity
.
Some properties make transition only when its property is named, all
will not work.
Timing function could be: ease
, linear
, ease-in
, ease-out
, ease-in-out
, step-start
, step-end
, cubic-bezier(number, number, number, number)
.
Following CSS Properties are Animatable.
Property Name | Type |
---|---|
background-color | as color |
background-position | as repeatable list of simple list of length, percentage, or calc |
border-bottom-color | as color |
border-bottom-width | as length |
border-left-color | as color |
border-left-width | as length |
border-right-color | as color |
border-right-width | as length |
border-spacing | as simple list of length |
border-top-color | as color |
border-top-width | as length |
bottom | as length, percentage, or calc |
clip | as rectangle |
color | as color |
font-size | as length |
font-weight | as font weight |
height | as length, percentage, or calc |
left | as length, percentage, or calc |
letter-spacing | as length |
line-height | as either number or length |
margin-bottom | as length |
margin-left | as length |
margin-right | as length |
margin-top | as length |
max-height | as length, percentage, or calc |
max-width | as length, percentage, or calc |
min-height | as length, percentage, or calc |
min-width | as length, percentage, or calc |
opacity | as number |
outline-color | as color |
outline-width | as length |
padding-bottom | as length |
padding-left | as length |
padding-right | as length |
padding-top | as length |
right | as length, percentage, or calc |
text-indent | as length, percentage, or calc |
text-shadow | as shadow list |
top | as length, percentage, or calc |
vertical-align | as length |
visibility | as visibility |
width | as length, percentage, or calc |
word-spacing | as length |
z-index | as integer |
This list comes from w3.org
Transitions for Image Backgrounds and CSS Gradients.
You can’t directly animate background images or CSS gradients (yet), but you may animate them with opacity stacked one on top of another.