An online markdown blog and knowledge repository.
Notes taken while learning how to animate website elements using CSS.
Learn CSS Animation in 15 Minutes
Two ways to animate:
Where to apply it?
:hover
pseudo property.Transition shorhand => delay, duration, property, timing-function. Enter one or all of these in the shorthand Property entry, rather than typing out up to 4 lines of properties.
Smooth transition: transition: transform 1s;
=> Works on translateX()
and other properties to smoothly transition between initial and ending "state".
timing function: Linear | ease-in-out |
Ease-in-out can be edited! Use the Inspect tool, find the timing function property, click on the function icon, and an editor appears with a bunch of built-in functions, and custom functions can be defined using the visual editing tool!
Minimal short-hand to get animation to work:
animation
Keyframes are needed to set steps:
@keyframes
Note: Once keyframes is done, the element resets back to it's originally set values.
To solve this use animation-fill-mode
: forwards | backwards | both | none | initial | inherit.
VSCode provides help so slow down while developing CSS properties and use those intellisense prompts to help find the correct sub-properties, and settings.
Return to conted-index.md