html - CSS 动画不会在 IE11 上的 iframe 中播放

标签 html css iframe internet-explorer-11

我目前正在编写一个 HTML5/JS Webapp,它将集成到预先存在的 HTML 代码中。预先存在的代码包含一个 iframe,然后加载我的 webapp 的 URL。

我在我的 CSS 文件中设置了以下动画:

@-moz-keyframes peopleSlideLeft {
  0% {
    left: -500px;
  }
  100% {
    left: 0px;
  }
}
@-webkit-keyframes peopleSlideLeft {
  0% {
    left: -500px;
  }
  100% {
    left: 0px;
  }
}
@keyframes peopleSlideLeft {
  0% {
    left: -500px;
  }
  100% {
    left: 0px;
  }
}

.container .left .people-container .people .person.slideInLeft {
  -webkit-animation: peopleSlideLeft 0.75s forwards;
  -moz-animation: peopleSlideLeft 0.75s forwards;
  animation: peopleSlideLeft 0.75s forwards;
}

现在,如果我在自己的窗口中启动我的 webapp,则动画播放没有问题,但是当通过 iframe 加载 webapp 时,动画不会触发(注意:此问题仅出现在 IE11.Chrome 中, Firefox 和 Edge 在 iframe 和外部都可以正常工作。

slideInLeft 类肯定附加到我要动画的 HTML 元素上,@keyframes 肯定在加载的 CSS 中,但动画仍然不会播放.

以下图片直接来自 IE11 Dev Console:

Class is attached to the div Keyframes show up in the CSS

有什么我想念的吗?

最佳答案

确保在末尾添加非前缀

 @-moz-keyframes peopleSlideLeft {
      0% {
        left: -500px;
      }
      100% {
        left: 0px;
      }
    }
    @-webkit-keyframes peopleSlideLeft {
      0% {
        left: -500px;
      }
      100% {
        left: 0px;
      }
    }
    @-ms-keyframes peopleSlideLeft {
      0% {
        left: -500px;
      }
      100% {
        left: 0px;
      }
    }
    @keyframes peopleSlideLeft {
      0% {
        left: -500px;
      }
      100% {
        left: 0px;
      }
    }

    .container .left .people-container .people .person.slideInLeft {
      -webkit-animation: peopleSlideLeft 0.75s forwards;
      -moz-animation: peopleSlideLeft 0.75s forwards;
      -ms-animation: peopleSlideLeft 0.75s forwards;
      animation: peopleSlideLeft 0.75s forwards;
    }

关于html - CSS 动画不会在 IE11 上的 iframe 中播放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43203609/

相关文章:

html - 如何实现响应式网页设计及其最佳实践

javascript - 如何通过 css 在文本之间添加额外的字符。已应用 Css 但显示错误结果

javascript - 标签难以点击

javascript - 当字符串是 Angular Iframe 标记时如何使用 innerHTML

JQuery .html() 和 .text() 在生产中返回空值

javascript - 如果存在样式标签,jQuery 的 .html 函数将无法正确将内容写入文本区域

javascript - 如何仅在 CSS 中创建具有绝对顶部和底部以及固定边的边框?包括图像

javascript - 如何在没有灰色任务栏的情况下在 HTML 上显示 PDF 文件?

javascript - 如何将变量从 iframe 传递到页面?

javascript - 如何使用 JavaScript 触发深层 div 内的 Checkbox 的 onChange?