html - 在 firefox 上播放动画时文本闪烁

标签 html css angularjs

我想使用 CSS 和 Angular Js 制作幻灯片动画。我是这样的:JSFiddle 在 chrome 上,此动画效果完美。但是在 Firefox 上,当动画继续播放时,文本会稍微抖动和闪烁。我无法找出确切的问题。任何想法..

代码:

HTML:

<div ng-controller="animationCtrl">
  <ul class='list'>
    <li>
        <div class="slide-animation">
            <div class="slide-animation-wrap new-slide-wrap {{cssTimeInfo1}}"> <span class="text">{{valueSet1[0]}}</span>

                <label class="small-label">{{valueSet2[1]}}</label>
            </div>
            <div class="slide-animation-wrap old-slide-wrap {{cssTimeInfo1}}"> <span class="text">{{valueSet1[1]}}</span>

                <label class="small-label">{{valueSet2[1]}}</label>
            </div>
        </div>
    </li>
   </ul>
</div>

CSS:

.list > li {
  box-sizing:border-box;  
  height: 72px;
  display: inline-block;
  margin-right: 1.06%;
  padding: 15px;
  vertical-align: top;
  background-color: #f1f1f1;
  -webkit-box-shadow: 0 0 7px rgba(210, 210, 210, 0.3) inset;
  box-shadow: 0 0 7px rgba(210, 210, 210, 0.3) inset;
}

.small-label {
  height: 24px;
  display: block;
  font-size: 0.714em;
  margin-bottom: 0;
  color: #999999;
  text-transform: uppercase;
  text-align: center;
}
.text {
  height: 24px;
  display: block;
  font-size: 1.286em;
  margin-bottom: 3px;
  color: #666666;
  text-align: center;
}



/* Slide animation */
.slide-animation {
  overflow: hidden;
  position: relative;
  height: 40px;
}
.slide-animation-wrap {
  position: relative;
  width: 100%;
}
.slide-animation-wrap.new-slide-wrap {
  top: -45px;
}
.slide-animation-wrap.old-slide-wrap {
  top: -51px;
}
.slide-animation-wrap.slide-in-animation,
.slide-animation-wrap.slide-out-animation {
  -webkit-animation: slide-outside-animation 1s linear forwards;
  -o-animation: slide-outside-animation 1s linear forwards;
  animation: slide-outside-animation 1s linear forwards;
}
.slide-animation-wrap:before,
.slide-animation-wrap:after {
  content: " ";
  display: table;
}
.slide-animation-wrap:after {
  clear: both;
}
.slide-animation-wrap:before,
.slide-animation-wrap:after {
  content: " ";
  display: table;
}
.slide-animation-wrap:after {
  clear: both;
}
@-webkit-keyframes slide-outside-animation {
  0% {
    -webkit-transform: translateY(0px);
    -ms-transform: translateY(0px);
    transform: translateY(0px);
  }
  100% {
    -webkit-transform: translateY(45px);
    -ms-transform: translateY(45px);
    transform: translateY(45px);
  }
}
@-moz-keyframes slide-outside-animation {
  0% {
    -webkit-transform: translateY(0px);
    -ms-transform: translateY(0px);
    transform: translateY(0px);
  }
  100% {
    -webkit-transform: translateY(45px);
    -ms-transform: translateY(45px);
    transform: translateY(45px);
  }
}
@-ms-keyframes slide-outside-animation {
  0% {
    -webkit-transform: translateY(0px);
    -ms-transform: translateY(0px);
    transform: translateY(0px);
  }
  100% {
    -webkit-transform: translateY(45px);
    -ms-transform: translateY(45px);
    transform: translateY(45px);
  }
}
@keyframes slide-outside-animation {
  0% {
    -webkit-transform: translateY(0px);
    -ms-transform: translateY(0px);
    transform: translateY(0px);
  }
  100% {
    -webkit-transform: translateY(45px);
    -ms-transform: translateY(45px);
    transform: translateY(45px);
  }
}

Angular :

var myApp = angular.module('myApp',[]);
myApp.controller('animationCtrl', ['$scope','$interval', function ($scope,$interval) {
    $scope.valueSet1=['HGFhgfsffghfhgf','HGFhgfsffghfhgf'];
    $scope.valueSet2=['ABC','ABC'];
    $scope.cssTimeInfo1 = "display-none";
    $scope.cssTimeInfo2 = "display-none";
    var flag=0;
    $interval(function(){
        //0
        $scope.cssTimeInfo1='slide-in-animation';
        $scope.cssTimeInfo2 = "display-none";
        flag++;
       if(flag>1){
           flag=0;
           //0

           $scope.cssTimeInfo1 = " ";
           $scope.cssTimeInfo2 = " ";

       }
        else{
           //1

           $scope.cssTimeInfo1 = "slide-out-animation";
           $scope.cssTimeInfo2 = "slide-in-animation";
       }
    },1000);

}]);

最佳答案

我在使用转换的 Firefox 上遇到了文本闪烁问题。添加

背面可见性:隐藏;

转换后的元素为我解决了这个问题。

关于html - 在 firefox 上播放动画时文本闪烁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32179300/

相关文章:

html - 如何使字体在 EPUB 中工作?

css - 我的 div 标签不适合

php - 如何在 php form_submit 按钮中添加样式或放置类

html - Material Design Lite - 复选框和列表在哪里?

javascript - AngularJS:没有 $scope 的 ng-repeat 中的变量在其本地范围内?

html - 异步加载图像

html - Bootstrap 4 列网格 - 响应度

css::before::after 对齐规则

javascript - 当 ng-show 为 false 时清除输入 ng-model AngularJS

angularjs ngHide与ngShow延迟