一个CSS3 动画执行完成后的问题...
迷茫
迷茫 2017-04-17 11:08:17
0
4
571

例:

在执行完一段css3动画后需要隐藏这个元素如何操作?也就是让它不重复动作.

使用animation参数forwards无效.

注:前提是不使用jQuery情况下能做到么?

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(4)
巴扎黑

To hide this, you can set opacity: 0

We can set the default opacity=0 for an element

Put the animation on each class, and then assign this class to this attribute

@keyframes ani{
    0%{opacity: 1}//此处显示转换为1 动画结束后就会自动隐藏了,因为元素的opacity为0,应该使用 display也可以,但我没用过,因为display没有动画效果
}
小葫芦

Is JavaScript acceptable without jQUery?

Depending on different types, two types of events will be triggered during animation playback:
1. AnimationEvent
2. TransitionEvent

The two implementations of the animation end event are:
1. animationend
2. transitionend

The Demo page is here, only Chrome has been tested:
http://codepen.io/longtian/pen/jEyrzN

For big compatibility pitfalls, you can see this part of the source code of AngularUI
https://github.com/angular-ui/bootstrap/blob/7512b93fecb6f27df4f5aeba4c756c0c36aebbf2/src/transition/transition.js#L59

刘奇

You can use js timer. Just set the timer time to be the same as the css animation time

小葫芦

http://jsfiddle.net/fevwehk3/

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template