For the Muze Dev Day, I want to make a simple example for each CSS animation and transition.
Certain CSS properties can be animated using CSS Animations or CSS Transitions. Animation means that their values can be made to change gradually over a given amount of time.
Source: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_animated_properties
Besides all, these properties are:
accent-colorbackdrop-filterbackgroundbackground-colorbackground-positionbackground-size
block-sizemax-block-sizemin-block-size
borderborder-bottomborder-leftborder-rightborder-topborder-colorborder-bottom-colorborder-left-colorborder-right-colorborder-top-color
border-widthborder-bottom-widthborder-left-widthborder-right-widthborder-top-width
border-radiusborder-bottom-left-radiusborder-bottom-right-radiusborder-end-end-radiusborder-end-start-radiusborder-start-end-radiusborder-start-start-radiusborder-top-left-radiusborder-top-right-radius
- Border Block
border-block-endborder-block-end-colorborder-block-end-widthborder-block-startborder-block-start-colorborder-block-start-width
border-image-outsetborder-image-sliceborder-image-width- Border Inline
border-inline-endborder-inline-end-colorborder-inline-end-widthborder-inline-startborder-inline-start-colorborder-inline-start-width
bottombox-shadowcaret-colorclipclip-pathcolor- Column
column-countcolumn-gapcolumn-rulecolumn-rule-colorcolumn-rule-widthcolumn-widthcolumns
filter- Flex
flexflex-basisflex-growflex-shrink
- Font
fontfont-sizefont-size-adjustfont-stretchfont-variation-settingsfont-weightletter-spacingline-heightword-spacing
- Grid
gapgrid-column-gapgrid-gapgrid-row-gapgrid-template-columnsgrid-template-rows
heightmax-heightmin-height
inline-sizemax-inline-sizemin-inline-size
- Inset
insetinset-blockinset-block-endinset-block-startinset-inlineinset-inline-endinset-inline-start
left- Margin
marginmargin-bottommargin-leftmargin-rightmargin-top
margin-block-endmargin-block-startmargin-inline-endmargin-inline-start
maskmask-bordermask-positionmask-size
object-positionoffsetoffset-anchoroffset-distanceoffset-pathoffset-positionoffset-rotate
opacityorderoutlineoutline-coloroutline-offsetoutline-width
- Padding
paddingpadding-bottompadding-leftpadding-rightpadding-top
padding-block-endpadding-block-startpadding-inline-endpadding-inline-start
perspectiveperspective-originrightrotaterow-gapscale- Scroll
- Scroll Margin
scroll-marginscroll-margin-blockscroll-margin-block-endscroll-margin-block-startscroll-margin-bottomscroll-margin-inlinescroll-margin-inline-endscroll-margin-inline-startscroll-margin-leftscroll-margin-rightscroll-margin-top
- Scroll Padding
scroll-paddingscroll-padding-blockscroll-padding-block-endscroll-padding-block-startscroll-padding-bottomscroll-padding-inlinescroll-padding-inline-endscroll-padding-inline-startscroll-padding-leftscroll-padding-rightscroll-padding-top
scroll-snap-coordinatescroll-snap-destinationscrollbar-color
- Scroll Margin
- Shape
shape-image-thresholdshape-marginshape-outside
tab-size- Text
text-decorationtext-decoration-colortext-decoration-thicknesstext-emphasistext-emphasis-colortext-indenttext-shadowtext-underline-offset
toptransformtransform-origintranslatevertical-alignvisibilitywidthmax-widthmin-width
z-indexzoom
Starting with transitions, I have two axis:
- CSS properties that can be animated
- CSS transition properties
The transition CSS property is shorthand for:
transition-delaytakes a<time>transition-durationtakes a<time>transition-propertyany property listed in the "Animatable CSS properties" sectiontransition-timing-functiontakes an<easing-function>
cubic-bezier(p1, p2, p3, p4)An author-defined cubic-Bezier curve, where the p1 and p3 values must be in the range of 0 to 1.ease(the default) Equal to cubic-bezier(0.25, 0.1, 0.25, 1.0), the default value, increases in velocity towards the middle of the transition, slowing back down at the end.ease-inEqual to cubic-bezier(0.42, 0, 1.0, 1.0), starts off slowly, with the transition speed increasing until complete.ease-outEqual to cubic-bezier(0, 0, 0.58, 1.0), starts transitioning quickly, slowing down the transition continues. •ease-in-outEqual to cubic-bezier(0.42, 0, 0.58, 1.0), starts transitioning slowly, speeds up, and then slows down again.linearEqual to cubic-bezier(0.0, 0.0, 1.0, 1.0), transitions at an even speed.steps( n, <jumpterm>)jump-startorstartDenotes a left-continuous function, so that the first jump happens when the transition begins;jump-endorendDenotes a right-continuous function, so that the last jump happens when the animation ends;jump-noneThere is no jump on either end. Instead, holding at both the 0% mark and the 100% mark, each for 1/n of the durationjump-bothIncludes pauses at both the 0% and 100% marks, effectively adding a step during the transition time.
step-startEqual to steps(1, jump-start)step-endEqual to steps(1, jump-end)
- either a positive or a negative number
- either an integer or a float
- use a unit (
msfor milliseconds,sfor seconds) - zero
0MUST be0msor0sto be valid
Source: https://developer.mozilla.org/en-US/docs/Web/CSS/time