css - 通过关键帧的多个背景图像位置的动画在 Chrome 和 Safari 中有效,但在 Firefox 中无效

标签 css animation background-image background-position keyframe

目标是创建一个无限滚动的两层视差背景。该效果在 Mac Chrome 和 Safari 中完美运行,但在 Firefox 中会断断续续。任何想法为什么?谢谢!

<style>
  body {
    background-color: black;
  }
  #container {
    bottom: 0; 
    left: 0;
    position: absolute;
    right: 0; 
    top: 0; 
  }
  @-webkit-keyframes scroll {
    100% { 
      background-position: 0 0; 
    }
  }
  @keyframes scroll {
    100% { 
      background-position: 0 0; 
    }
  }
  .bg1 {
    -webkit-animation: scroll 2.5s linear infinite;
    animation: scroll 2.5s linear infinite;
    background-image: url(path/to/image);
    background-position: 0 -156px;
    background-size: 128px 156px;
    height: 100%;
    opacity: 0.5;
    position: fixed;
    width: 100%;
  }
  .bg2 {
    -webkit-animation: scroll 5s linear infinite;
    animation: scroll 5s linear infinite;
    background-image: url(path/to/image);
    background-position: 0 -78px;
    background-size: 64px 78px;
    height: 100%;
    opacity: 0.25;
    position: fixed;
    width: 100%;
  }
</style>

<body>
  <div id="container">
    <div id="bg1" class="bg1"></div>
    <div id="bg2" class="bg2"></div>
  </div>
</body>

最佳答案

您的代码中没有任何 -moz- 属性。 -webkit- 在 chrome 和 safari 中均受支持。 但是对于 firefox 你应该在一些旧版本中有 -moz-prefix。

关于css - 通过关键帧的多个背景图像位置的动画在 Chrome 和 Safari 中有效,但在 Firefox 中无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24565437/

相关文章:

css - Twitter Bootstrap 2 顶部导航下拉列表被子导航栏覆盖

javascript - 显示/隐藏具有多个 Div ID 的功能

css - 使用 jQuery 创建背景图像循环

css - 背景图像拉伸(stretch)的内联样式

android - android中按钮的背景图像

css - 使用 swfobject 时,swf 文件会忽略 z-index

html - 我的 CSS 的某些部分不起作用

HTML <table> 不适合容器(总是更大)

javascript - jQuery 在卸载前播放动画?

python - 添加补丁时 Matplotlib 动画速度变慢