Animate.css in hover

user3198605 picture user3198605 · Jan 17, 2014 · Viewed 37.5k times · Source

Today I tried to implement in my site animate.css

But I wanted to make sure that the 'effect is activated in the: hover So I used jquery for this

The code is :

 $(".questo").hover( function (e) {
    $(this).toggleClass('animated shake', e.type === 'mouseenter');
});

The problem is that once you remove the mouse, the 'effect is interrupted. It could land the 'effect even without hover effect once it has begun?

Thank you all in advance

Answer

Ben Leitner picture Ben Leitner · Jul 22, 2015

In your CSS file you could just add:

.questo:hover {
    -webkit-animation: shake 1s;
    animation: shake 1s;
}

The nice thing about this solution is that it requires no JavaScript. For reference look at this page