当使用变换和位置放在一起时,CSS动画不会在IE11上工作

时间:2017-11-30 14:54:31

标签: css css3 transform css-animations css-transforms

@keyframes marquee2 {}无法在Internet Explorer 11上运行,也无法在Edge上完美运行。所有其他主流浏览器,如Firefox或Chrome都运行良好。还是不知道打破动画的原因是什么。将lefttransform: translate(0, 0)一起使用时,为什么动画无效?

演示:https://codepen.io/athimannil/full/bojLQN



body {
  min-height: 100vh;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
}

.container {
  width: 90vw;
}

.container {
  overflow: hidden;
  position: relative;
  height: 200px;
}

.marquee-wrap {
  position: absolute;
  display: -webkit-inline-box;
  display: -ms-inline-flexbox;
  display: inline-flex;
  -webkit-animation: marquee2 20s linear infinite;
  animation: marquee2 20s linear infinite;
}

.marquee-wrap .marquee-img {
  width: 200px;
  padding: 0 1rem;
}

.marquee-wrap .marquee-img img {
  max-width: 100%;
}

@-webkit-keyframes marquee2 {
  0% {
    left: 0;
    -webkit-transform: translate(0, 0);
    transform: translate(0, 0);
  }
  50% {
    left: 100%;
    -webkit-transform: translate(-100%, 0);
    transform: translate(-100%, 0);
  }
  100% {
    left: 0;
    -webkit-transform: translate(0, 0);
    transform: translate(0, 0);
  }
}

@keyframes marquee2 {
  0% {
    left: 0;
    -webkit-transform: translate(0, 0);
    transform: translate(0, 0);
  }
  50% {
    left: 100%;
    -webkit-transform: translate(-100%, 0);
    transform: translate(-100%, 0);
  }
  100% {
    left: 0;
    -webkit-transform: translate(0, 0);
    transform: translate(0, 0);
  }
}

<div class="container">
  <div class="marquee-wrap">
    <div class="marquee-img"><img src="http://via.placeholder.com/200x200?text=Logo 01" alt=""></div>
    <div class="marquee-img"><img src="http://via.placeholder.com/200x200?text=Logo 02" alt=""></div>
    <div class="marquee-img"><img src="http://via.placeholder.com/200x200?text=Logo 03" alt=""></div>
    <div class="marquee-img"><img src="http://via.placeholder.com/200x200?text=Logo 04" alt=""></div>
    <div class="marquee-img"><img src="http://via.placeholder.com/200x200?text=Logo 05" alt=""></div>
    <div class="marquee-img"><img src="http://via.placeholder.com/200x200?text=Logo 06" alt=""></div>
    <div class="marquee-img"><img src="http://via.placeholder.com/200x200?text=Logo 07" alt=""></div>
    <div class="marquee-img"><img src="http://via.placeholder.com/200x200?text=Logo 08" alt=""></div>
    <div class="marquee-img"><img src="http://via.placeholder.com/200x200?text=Logo 09" alt=""></div>
    <div class="marquee-img"><img src="http://via.placeholder.com/200x200?text=Logo 10" alt=""></div>
  </div>
</div>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

不幸的是,或者更确切地说,我没有IE 11或Edge进行测试,但caniuse.com的这些要点可能会导致您的问题

  • Windows 7上的IE10和IE11有一个错误,当在动画测试用例中使用时,转换变换值总是被解释为像素
  • IE10和IE11不支持媒体查询中的CSS关键帧块。必须在媒体查询定义之外定义。示例

来源:https://caniuse.com/#feat=css-animation