我对如何使用CSS动画对元素单击的内容进行动画处理感到困惑。

我可以在工作中设置动画,但是出于某种原因,动画无法执行任何操作。我换出了类名,以切换不同的动画,名称切换得很好,但是动画效果不佳。

如果有人能为我指出我的错误,我将不胜感激。

抱歉,我知道很多代码。

这是我的SCSS:

.animate-in .twitter, .animate-in .google-plus, .animate-in .facebook,
.animate-out .twitter, .animate-out .google-plus, .animate-out .facebook{
    @include animation-name(dropIn, fadeIn, dropShadow);
    @include animation-duration(500ms);
    @include animation-delay(0ms);
    @include animation-direction(alternate);
    @include animation-fill-mode(forwards);

}
.animate-out .twitter, .animate-out .google-plus, .animate-out .facebook{
    @include animation-name(fadeOut);
    @include animation-duration(500ms);
    @include animation-delay(0ms);
    @include animation-play-state(play);
    @include animation-fill-mode(forwards);
}
.animate-in .google-plus,
.animate-out .google-plus{
    @include animation-delay(150ms);
    @include animation-timing-function(cubic-bezier(0.77, 0, 0.175, 1));
}
.animate-in .facebook,
.animate-out .facebook{
    @include animation-delay(400ms);
}


以及关键帧:

$dropHeight:90px;
@include keyframes(dropIn) {
    0% {
          @include transform(  translateY(-$dropHeight) rotate(-20deg) scale(2,4) );

    }
    100% {
      @include transform( translateY(0px) rotate(0deg) scale(1,1) );
    }
}
@include keyframes(dropShadow) {
    0% {
          @include text-shadow(-$dropHeight $dropHeight 10px rgba($darkBlue,0.2));

    }
    100% {
      @include text-shadow(0 0 1px darken($darkBlue,3%));
    }
}
@include keyframes(fadeIn) {
    from {
      opacity:0;
    }
    to {
      opacity:1;
    }
  }
 @include keyframes(fadeOut) {
    from {
      opacity:1;
    }
    to {
      opacity:0;
    }
  }


我正在使用此JS来切换按钮:

$('.navbar-toggle').on('click', function() {
  $('div.navbar-collapse.collapse').toggleClass('animate-out').toggleClass('animate-in');
});


然后还有HTML:

<button type="button" data-toggle="collapse" data-target=".navbar-collapse" class="navbar-toggle collapsed">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span><span class="icon-bar">
</span><span class="icon-bar"></span>
</button>
<div class="navbar-collapse animate-out collapse" style="height: 133px;">
    <ul class="nav navbar-nav">
       <li class="facebook active"><a href="#about"> <i class="fa fa-facebook"> </i><span class="text-hide">Facebook</span></a></li>
       <li class="twitter"><a href="#"> <i class="fa fa-twitter"> </i><span class="text-hide">Twitter</span></a></li>
       <li class="google-plus"><a href="#contact"> <i class="fa fa-google-plus"> </i><span class="text-hide">Google+</span></a></li>
     </ul>
 </div>

最佳答案

您是否尝试过.fadeIn().fadeOut()

这应该工作而不必编写所有CSS

09-27 01:12
查看更多