【发布时间】:2020-09-07 13:48:08
【问题描述】:
在 CSS 级联和继承模块中解释了带有 !important 注释的声明比起源于动画的样式更重要。
当我自己进行测试时,我意识到没有任何样式可以防止动画运行时覆盖 css 属性。
例子:
.box{
background-color: green!important;
animation: animacion 2s;
height: 50px;
width: 50px;
}
@keyframes animacion {
from{
background-color: yellow;
}
to{
background-color: blue;
margin-left: 50px;
}
}
<div class="box"></div>
在此示例中,当动画运行时,background-color 已更改。
如果我使用animation-fill-mode: forwards 使最后一个关键帧中给出的值被元素保留,该值将用!important 覆盖该值。
在我看来,这种行为与规范所说的相反,或者我可能不明白他们想说什么。
【问题讨论】:
-
您使用什么浏览器进行测试?动画不应运行
-
动画在 chrome 上运行,使用 mac
标签: html css css-animations css-cascade