- CSS 教程
- CSS - 首頁
- CSS - 路線圖
- CSS - 簡介
- CSS - 語法
- CSS - 選擇器
- CSS - 匯入
- CSS - 度量單位
- CSS - 顏色
- CSS - 背景
- CSS - 字型
- CSS - 文字
- CSS - 圖片
- CSS - 連結
- CSS - 表格
- CSS - 邊框
- CSS - 塊級邊框
- CSS - 內聯邊框
- CSS - 外邊距
- CSS - 列表
- CSS - 內邊距
- CSS - 游標
- CSS - 輪廓
- CSS - 尺寸
- CSS - 捲軸
- CSS - 內聯塊
- CSS - 下拉選單
- CSS - 可見性
- CSS - 溢位
- CSS - 清除浮動
- CSS - 浮動
- CSS - 箭頭
- CSS - 調整大小
- CSS - 引號
- CSS - 順序
- CSS - 定位
- CSS - 連字元
- CSS - 懸停
- CSS - 顯示
- CSS - 聚焦
- CSS - 縮放
- CSS - 位移
- CSS - 高度
- CSS - 連字元字元
- CSS - 寬度
- CSS - 不透明度
- CSS - z-index
- CSS - 底部
- CSS - 導航欄
- CSS - 疊加層
- CSS - 表單
- CSS - 對齊
- CSS - 圖示
- CSS - 圖片庫
- CSS - 註釋
- CSS - 載入器
- CSS - 屬性選擇器
- CSS - 組合器
- CSS - 根元素
- CSS - 盒模型
- CSS - 計數器
- CSS - 剪裁
- CSS - 書寫模式
- CSS - Unicode 雙向演算法
- 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 高階
- CSS - 網格
- CSS - 網格佈局
- CSS - Flexbox
- CSS - 可見性
- CSS - 定位
- CSS - 層
- CSS - 偽類
- CSS - 偽元素
- CSS - @規則
- CSS - 文字效果
- CSS - 分頁媒體
- CSS - 列印
- CSS - 佈局
- CSS - 驗證
- CSS - 圖片精靈
- CSS - !important
- CSS - 資料型別
- CSS3 教程
- CSS3 - 教程
- CSS - 圓角
- CSS - 邊框圖片
- CSS - 多重背景
- CSS - 顏色
- CSS - 漸變
- CSS - 盒陰影
- CSS - 盒裝飾中斷
- CSS - 游標顏色
- CSS - 文字陰影
- CSS - 文字
- CSS - 二維變換
- CSS - 三維變換
- CSS - 過渡
- CSS - 動畫
- CSS - 多列
- CSS - 盒尺寸
- CSS - 工具提示
- CSS - 按鈕
- CSS - 分頁
- CSS - 變數
- CSS - 媒體查詢
- CSS - 函式
- CSS - 數學函式
- CSS - 遮罩
- CSS - 形狀
- CSS - 樣式圖片
- CSS - 特異性
- CSS - 自定義屬性
- CSS 響應式
- CSS RWD - 簡介
- CSS RWD - 視口
- CSS RWD - 網格檢視
- CSS RWD - 媒體查詢
- CSS RWD - 圖片
- CSS RWD - 影片
- CSS RWD - 框架
- CSS 工具
- CSS - PX到EM轉換器
- CSS - 顏色選擇器和動畫
- CSS 資源
- CSS - 有用資源
- CSS - 討論
CSS - 動畫組合屬性
CSS 屬性 `animation-composition` 定義了當多個動畫同時作用於同一屬性時要應用的複合操作。
在 CSS 動畫中,`@keyframes` 針對的屬性具有關聯的效果堆疊。
效果堆疊的值是由 CSS 樣式規則中的底層屬性值與關鍵幀中屬性的效果值組合產生的。
`animation-composition` 屬性定義了為特定屬性組合這些值的方法。
可能的值
`replace` - 預設值為效果值,優先於屬性的底層值。
`add` - 效果值透過加法運算增加現有屬性值。對於加法運算不滿足交換律的動畫型別,運算元的順序為基值後跟效果值。
`accumulate` - 效果值和底層值合併。對於加法運算不滿足交換律的動畫型別,運算元的順序為基值後跟效果值。
語法
animation-composition = <single-animation-composition># <single-animation-composition> = replace | add | accumulate
應用於
所有 HTML 元素。
CSS animation-composition - replace 值
以下示例演示了在 `animation-composition` 中使用 `replace` 值。`replace` 組合 ( `#replace-demo` ) 會導致盒子在每次動畫迭代開始時重置到其起始位置,並完全替換先前狀態。
<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 值
以下示例演示了在 `animation-composition` 中使用 `add` 值。`add` 組合 ( `#add-demo` ) 會產生累加效果,其中盒子在每次迭代中都會進一步向右移動,因為位移是累積的。
<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 值
以下示例演示了在 `animation-composition` 中使用 `accumulate` 值。`accumulate` 組合 ( `#accumulate-demo` ) 也累積變換,但與 `add` 不同,它保留了先前的狀態而無需重置,導致在多次迭代中連續累積平移。
<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>
廣告