【问题标题】:CSS Animation Fade In pause.... Fade OutCSS 动画淡入暂停.... 淡出
【发布时间】:2014-11-11 11:39:32
【问题描述】:

我正在尝试让一些(将是图像)块淡入暂停几秒钟,然后淡出....

到目前为止我已经得到它,但它似乎不想淡出,我不确定我哪里出错了。

淡出之后又出现了。

我有一个fiddle,它非常基本地显示了它。

/* Defines the animation keyframes */
@-webkit-keyframes fadein {
0% {
     opacity: 0;
 }

 72% {
     opacity: 0;
 }

 100% {
     opacity: 1;
 } 
}
@-moz-keyframes fadein {
  0% {
       opacity: 0;
   }

   72% {
       opacity: 0;
   }

   100% {
       opacity: 1;
   } 
}
@keyframes fadein {
 0% {
      opacity: 0;
  }

  72% {
      opacity: 0;
  }

  100% {
      opacity: 1;
  }

}


/* Defines the animation keyframes */
@-webkit-keyframes fadeOut {
0% {
     opacity: 1;
 }

 72% {
     opacity: 0;
 }

 100% {
     opacity: 0;
 } 
}
@-moz-keyframes fadeOut {
  0% {
         opacity: 1;
     }

     72% {
         opacity: 0;
     }

     100% {
         opacity: 0;
     } 
}
@keyframes fadeOut {
 0% {
        opacity: 1;
    }

    72% {
        opacity: 0;
    }

    100% {
        opacity: 0;
    } 

}

.get{
  -webkit-animation: fadein 1.9s ease-in-out 0s 1, 
    fadeOut 1.9s ease-in-out 5s 1 ; 
 -moz-animation: fadein 1.9s ease-in-out 0s 1, 
    fadeOut 1.9s ease-in-out 5s 1 ;
  animation: fadein 1.9s ease-in-out 0s 1, 
    fadeOut 1.9s ease-in-out 5s 1 ;

   background-color:red;
}



 .give{
   -webkit-animation: fadein 2.8s ease-in-out both 0s 1, 
    fadeOut 1.9s ease-in-out 8s 1 ;  ; 
   -moz-animation: fadein 2.8s ease-in-out both 0s 1, 
    fadeOut 1.9s ease-in-out 8s 1 ; 
   animation: fadein 2.8s ease-in-out both 0s 1, 
    fadeOut 1.9s ease-in-out 8s 1 ; 
     background-color:green;
   }

【问题讨论】:

  • 将所有内容放在一个动画中并解决延迟问题
  • 对不起,我才刚刚开始接触 css 动画,所以不确定你的意思?

标签: css animation css-animations


【解决方案1】:

使用单个动画 ...

*{
  margin:0;
  padding:0;
}
.block{

  width:100px;
  height:100px
  display:block;
  height:100px;
}


@keyframes fadein {
  0%, 100% {
    opacity: 0;
  }

  72% {
    opacity: 1;
  }

}

.get{
  opacity: 0;
  animation: fadein 2s ease-in-out 0s 1;  
  background-color:red;
}



.give{
  opacity: 0;
  animation: fadein 3s ease-in-out both 1s 1;
  background-color:green;
}
<script src="//cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
<div class="block get">Get</div>
<div class="block give">Give</div>

【讨论】:

  • 谢谢!哪个元素控制它暂停的时间?
  • 动画中的百分比。
  • 哦,我明白了,所以我通过关键帧控制暂停,抱歉我有点笨,这是我第一次接触 css 动画?
猜你喜欢
  • 2021-02-19
  • 2019-02-11
  • 1970-01-01
  • 2016-05-12
  • 1970-01-01
  • 2013-07-14
  • 1970-01-01
  • 1970-01-01
  • 2013-05-19
相关资源
最近更新 更多