- CSS Tutorial
- CSS - Home
- CSS - Introduction
- CSS - Syntax
- CSS - Selectors
- CSS - Inclusion
- CSS - Measurement Units
- CSS - Colors
- CSS - Backgrounds
- CSS - Fonts
- CSS - Text
- CSS - Images
- CSS - Links
- CSS - Tables
- CSS - Borders
- CSS - Border Block
- CSS - Border Inline
- CSS - Margins
- CSS - Lists
- CSS - Padding
- CSS - Cursor
- CSS - Outlines
- CSS - Dimension
- CSS - Scrollbars
- CSS - Inline Block
- CSS - Dropdowns
- CSS - Visibility
- CSS - Overflow
- CSS - Clearfix
- CSS - Float
- CSS - Arrows
- CSS - Resize
- CSS - Quotes
- CSS - Order
- CSS - Position
- CSS - Hyphens
- CSS - Hover
- CSS - Display
- CSS - Focus
- CSS - Zoom
- CSS - Translate
- CSS - Height
- CSS - Hyphenate Character
- CSS - Width
- CSS - Opacity
- CSS - Z-Index
- CSS - Bottom
- CSS - Navbar
- CSS - Overlay
- CSS - Forms
- CSS - Align
- CSS - Icons
- CSS - Image Gallery
- CSS - Comments
- CSS - Loaders
- CSS - Attr Selectors
- CSS - Combinators
- CSS - Root
- CSS - Box Model
- CSS - Counters
- CSS - Clip
- CSS - Writing Mode
- CSS - Unicode-bidi
- CSS - min-content
- CSS - All
- CSS - Inset
- CSS - Isolation
- CSS - Overscroll
- CSS - Justify Items
- CSS - Justify Self
- CSS - Tab Size
- CSS - Pointer Events
- CSS - Place Content
- CSS - Place Items
- CSS - Place Self
- CSS - Max Block Size
- CSS - Min Block Size
- CSS - Mix Blend Mode
- CSS - Max Inline Size
- CSS - Min Inline Size
- CSS - Offset
- CSS - Accent Color
- CSS - User Select
- CSS Advanced
- CSS - Grid
- CSS - Grid Layout
- CSS - Flexbox
- CSS - Visibility
- CSS - Positioning
- CSS - Layers
- CSS - Pseudo Classes
- CSS - Pseudo Elements
- CSS - @ Rules
- CSS - Text Effects
- CSS - Paged Media
- CSS - Printing
- CSS - Layouts
- CSS - Validations
- CSS - Image Sprites
- CSS - Important
- CSS - Data Types
- CSS3 Tutorial
- CSS3 - Tutorial
- CSS - Rounded Corner
- CSS - Border Images
- CSS - Multi Background
- CSS - Color
- CSS - Gradients
- CSS - Box Shadow
- CSS - Box Decoration Break
- CSS - Caret Color
- CSS - Text Shadow
- CSS - Text
- CSS - 2d transform
- CSS - 3d transform
- CSS - Transition
- CSS - Animation
- CSS - Multi columns
- CSS - Box Sizing
- CSS - Tooltips
- CSS - Buttons
- CSS - Pagination
- CSS - Variables
- CSS - Media Queries
- CSS - Functions
- CSS - Math Functions
- CSS - Masking
- CSS - Shapes
- CSS - Style Images
- CSS - Specificity
- CSS - Custom Properties
- CSS Responsive
- CSS RWD - Introduction
- CSS RWD - Viewport
- CSS RWD - Grid View
- CSS RWD - Media Queries
- CSS RWD - Images
- CSS RWD - Videos
- CSS RWD - Frameworks
- CSS References
- CSS - Questions and Answers
- CSS - Quick Guide
- CSS - References
- CSS - Color References
- CSS - Web browser References
- CSS - Web safe fonts
- CSS - Units
- CSS - Animation
- CSS Resources
- CSS - Useful Resources
- CSS - Discussion
CSS - animation-composition Property
The CSS property animation-composition defines the composite operation to be applied when multiple animations act on the same property at the same time.
In CSS animations, properties targeted by @keyframes have associated effect stacks.
The value of the effect stack results from the combination of the underlying property value in the CSS style rule with the effect value of the property in keyframe.
The animation-composition property defines the method for combining these values for a specific property.
Possible Values
replace - The default value is the effect value, which takes precedence over the underlying value of the property.
add - The effect value increases the existing property value through an additive operation. For animation types where the add operation is not commutative, the order of operands is the base value followed by the effect value.
accumulate - The effect and the underlying values are merged. In animation types where the addition operation is not commutative, the order of operands is the base value followed by the effect value.
Syntax
animation-composition = <single-animation-composition># <single-animation-composition> = replace | add | accumulate
Applies To
All the HTML elements.
CSS animation-composition - replace Value
The following example demonstrates the usage of value replace in animation-composition. The replace composition (#replace-demo) causes the box to be reset to its starting position at the beginning of each animation iteration and completely replaces the previous state.
<html> <head> <style> @keyframes moveRight { 0%, 100% { transform: translateX(0); background-color: lightblue; } 50% { transform: translateX(100px); background-color: lightcoral; } } .box { width: 100px; height: 100px; margin: 20px; display: inline-block; animation-duration: 2s; animation-iteration-count: infinite; border: 2px solid #333; } #replace-demo { animation-name: moveRight; animation-composition: replace; } .container { text-align: center; margin-top: 50px; } .label { font-weight: bold; margin-bottom: 10px; } </style> </head> <body> <div class="container"> <div class="label">Replace Composition</div> <div class="box" id="replace-demo"></div> </div> </body> </html>
CSS animation-composition - add Value
The following example demonstrates the usage of add value in animation-composition. The add composition (#add-demo) leads to an additive effect in which the box is shifted further to the right with each iteration, as the shift is accumulated.
<html> <head> <style> @keyframes moveRight { 0%, 100% { transform: translateX(0); background-color: lightblue; } 50% { transform: translateX(100px); background-color: lightcoral; } } .box { width: 100px; height: 100px; margin: 20px; display: inline-block; animation-duration: 2s; animation-iteration-count: infinite; border: 2px solid #333; } #add-demo { animation-name: moveRight; animation-composition: add; } .container { text-align: center; margin-top: 50px; } .label { font-weight: bold; margin-bottom: 10px; } </style> </head> <body> <div class="container"> <div class="label">Add Composition</div> <div class="box" id="add-demo"></div> </div> </body> </html>
CSS animation-composition - accumulate Value
The following example demonstrates the usage of accumulate value in animation-composition. The accumulate composition (#accumulate-demo) also accumulates transformations but, unlike add, retains the previous states without resetting, leading to a continuous build-up of translations over multiple iterations.
<html> <head> <style> @keyframes moveRight { 0%, 100% { transform: translateX(0); background-color: lightblue; } 50% { transform: translateX(100px); background-color: lightcoral; } } .box { width: 100px; height: 100px; margin: 20px; display: inline-block; animation-duration: 2s; animation-iteration-count: infinite; border: 2px solid #333; } #accumulate-demo { animation-name: moveRight; animation-composition: accumulate; } .container { text-align: center; margin-top: 50px; } .label { font-weight: bold; margin-bottom: 10px; } </style> </head> <body> <div class="container"> <div class="label">Accumulate Composition</div> <div class="box" id="accumulate-demo"></div> </div> </body> </html>
To Continue Learning Please Login
Login with Google