css - !important 关键帧动画

标签 css keyframe

关键帧动画规范 says !important 将在关键帧中被忽略——如果在动画声明中内联设置则无效。

来自示例规范:

@keyframes important1 {
  from { margin-top: 50px; }
  50%  { margin-top: 150px !important; } /* ignored */
  to   { margin-top: 100px; }
}

@keyframes important2 {
  from { margin-top: 50px;
         margin-bottom: 100px; }
  to   { margin-top: 150px !important; /* ignored */
         margin-bottom: 50px; }
}

是否有已知的解决方法?

最佳答案

实际上只有两个选择:

  1. 重写 CSS 代码以避免使用 !important
  2. 使用 JavaScript 动画代替 CSS 动画。 JavaScript 解决方案将能够改变任何内联样式甚至文档级 stylesheets如有必要

关于css - !important 关键帧动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34210982/

相关文章:

layout - css hover 创建边框但推送内容

html - CSS3 关键帧动画 - 类

ffmpeg - 在编码时强制自定义 H.264 帧内(关键帧)?

html - 在 mozilla 中,第一个 css keyframe 在你悬停时第二次工作正常,它只是消失了

css - 在@media 中嵌套@keyframe

html - CSS 行内 block 尺寸差异

将宽度设置为 100% 后 HTML 没有响应

javascript - Bootstrap DateTimePicker (Eonasdan) 未显示

html - 为什么我在使用 css 中的关键帧设置动画时会丢失光标样式和 onclick 功能(仅在 Google Chrome 中)?

html - CSS下拉列表中元素的对齐