可以使用逗号分隔动画名称,来为同一个元素添加多个动画效果。
示例代码:
@keyframes animation-1 { from { transform: scale(1); } to { transform: scale(1.5); } } @keyframes animation-2 { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } .element { animation: animation-1 2s ease, animation-2 2s linear; }
在上面的例子中,我们创建了两个动画:animation-1和animation-2。然后我们在元素的样式中使用了 animation
属性将这两个动画同时应用在元素上。我们在 animation
属性中使用逗号 ,
分隔动画名称,这样就可以为同一个元素添加多个动画效果了。