Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Animate.css in hover

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

like image 877
user3198605 Avatar asked Jan 17 '14 09:01

user3198605


People also ask

What is a CSS hover animation?

What is a CSS hover animation? A CSS hover animation occurs when a user hovers over an element, and the element responds with motion or another transition effect. It's used to highlight key items on a web page and it's an effective way to enhance your site's interactivity.

How do you use transition on hover in CSS?

Transition on Hover. CSS transitions allows you to change property values smoothly (from one value to another), over a given duration. Add a transition effect (opacity and background color) to a button on hover: Fade in on hover:

How to remove a class from a hover animation?

Instead of use toggleClass, change your code by adding the class in hover, and hook for the animation end css3 to finish and than remove the class.

What are the Best CSS hover effects?

Fade Siblings on Hover 12. Pure CSS Blur Hover Effect 13. Button Hover Effects 14. Glitch Hover Effect 15. Thumbnail Hover Effect


2 Answers

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

like image 104
Ben Leitner Avatar answered Sep 28 '22 04:09

Ben Leitner


See this variant (more interactive):

$(".myDiv").hover(function(){
    $(this).addClass('animated ' + $(this).data('action'));
});
$(".myDiv").bind("animationend webkitAnimationEnd oAnimationEnd MSAnimationEnd",function(){
    $(this).removeClass('animated ' + $(this).data('action'));
});

http://jsfiddle.net/DopustimVladimir/Vc2ug/

like image 39
DopustimVladimir Avatar answered Sep 28 '22 04:09

DopustimVladimir