N
N
Nikolay2014-06-30 14:55:52
css
Nikolay, 2014-06-30 14:55:52

How to make a css animation to hide an element?

The bottom line is, if you set an animation to an element through keyframes, then it will always be executed when the element becomes visible. Example - jsfiddle.net/Zvyxd
Is it somehow possible to achieve the opposite effect when an element becomes display: none;?

Answer the question

In order to leave comments, you need to log in

6 answer(s)
V
Vadim Belkin, 2014-06-30
@BelkinVadim

Do you want to make it fade in and out? If so, why keyframes? You can make an additional class for an element that is responsible for hiding or showing it. And delete it or add it.
jsfiddle.net/YxsTV

V
Vitaly Kirenkov, 2014-06-30
@DeLaVega

jsfiddle.net/Zvyxd/5
I wrote a very hackish hastily, but you should understand the logic why the animation will work.

I
isxaker, 2014-06-30
@isxaker

Updated
I recently did this
Link

S
Sergey Melnikov, 2014-06-30
@mlnkv

jsfiddle.net/Zvyxd/10

T
twixoff, 2014-06-30
@twixoff

Create two classes with different animations - one for appearing and one for hiding.
Then just add the required class depending on the situation - show or hide.

N
Nikolai Styazhkin, 2015-09-29
@elgringo

How to hide example_block on second click on "Show Element"?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question