html - CSS 动画在 Chrome 中不起作用

标签 html css google-chrome css-animations

我插入了一些 CSS 动画。它们在 FireFox 中运行良好,但在 Chrome 中运行不佳。有什么办法可以解决这个问题吗?

这是我的代码,我有一张移动缓慢的背景图片。底部有一个移动速度更快的动画。

body {
  background-image: url('images/bg.png');
  animation: animatedSky 40s linear infinite;
}

@keyframes animatedSky {
    from { background-position: 100% 0; }
    to { background-position: 0 0; }
}

#bottom { 
   width: 100%; 
   height: 40px; 
   background-image: url('images/bottom.png');
   background-position: 0px 0px;
   background-repeat: repeat-x;
   animation: animatedBackground 8s linear infinite;
   position: absolute;
   margin-top: 600px;
   }

@keyframes animatedBackground {
    from { background-position: 100% 0; }
    to { background-position: 0 0; }
    }

最佳答案

对于 chrome 和 safari 中的关键帧,您需要使用 webkit 前缀:

@-webkit-keyframes

关于html - CSS 动画在 Chrome 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22137645/

相关文章:

html - Chrome 77 缓存 <select> 选定的选项,即使具有自动完成功能 ="off"

jquery - 输入中的 Bootstrap 表单组

javascript - 如何用 JavaScript 替换 Html `table` 中的第一个 `th` Html 标签 `td` Html 标签

css - 使用 before 标签在 css 中居中文本

javascript - Google Chrome 中的按键事件检测失败

javascript - HTML组件开发。具有浏览器自动重新加载功能的轻量级快速解决方案

html - 如何向我的网站添加新的 flaticons?

html - 默认静音 HTML5 视频,但允许用户取消静音

jQuery 下一个/上一个按钮在 IE7 中不能正常工作

javascript - 在客户端编译 LESS?