On this page
Custom Properties & Animation
Prev: Typography & Color | Up: properties | Next: functions
Rel: Keyframes, Fonts & Entry Animations, Reflow, Repaint & Performance
Ref: MDN Web Docs — Using CSS Custom Properties
Tags: #public #web #css #properties #animation
Contents
CSS Custom Properties (--var)
Custom properties participate in the cascade and inheritance at runtime and can be read or updated from JavaScript via el.style.setProperty("--accent", ...).
:root {
--space-md: 1rem;
--surface: oklch(98% 0.005 260);
}
.card {
padding: var(--space-md);
background: var(--surface);
}
Transitions, Transforms & Motion Preferences
Animate compositor-friendly properties (transform, opacity) instead of layout properties (top, width, margin) to stay at 60+ fps, and always respect prefers-reduced-motion:
.btn {
transition: transform 150ms ease, opacity 150ms ease;
}
.btn:hover {
transform: translateY(-1px);
}
@media (prefers-reduced-motion: reduce) {
.btn { transition: none; }
}
Linked from
- tuts/css/at_rules/keyframes_and_fonts
- tuts/css/at_rules/layers_and_scope
- tuts/css/functions
- tuts/css/properties
- tuts/css/properties/custom_properties_and_animation
- tuts/css/properties/motion
- tuts/css/properties/motion/animation
- tuts/css/properties/motion/opacity
- tuts/css/properties/motion/transform
- tuts/css/properties/motion/transition
- tuts/css/properties/motion/will-change
- tuts/css/properties/typography_and_color
- tuts/css/tutorials/responsive_design_and_theming
- tuts/web/rendering
- tuts/web/rendering/reflow_repaint_and_performance
Related notes
- tuts/css/at_rules/keyframes_and_fonts Linked here; links to this page; shared tags: #animation, #css, #web
- tuts/css/properties Linked here; links to this page; shared tags: #css, #properties, #web
- tuts/css/properties/typography_and_color Linked here; links to this page; shared tags: #css, #properties, #web
- tuts/css/functions Linked here; links to this page; shared tags: #css, #web
- tuts/web/rendering/reflow_repaint_and_performance Linked here; links to this page; shared tags: #web
- tuts/css/properties/motion links to this page; shared tags: #css, #properties, #web
- tuts/css/properties/motion/animation links to this page; shared tags: #css, #properties, #web
- tuts/css/properties/motion/opacity links to this page; shared tags: #css, #properties, #web
- tuts/css/properties/motion/transform links to this page; shared tags: #css, #properties, #web
- tuts/css/properties/motion/transition links to this page; shared tags: #css, #properties, #web