Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use :hover to trigger a CSS3 animation (or transition) which keeps running even when the mouse is no longer hovering

I'm creating a link list where one link container expands when hovering it ( with details, image and description). I have no problems to animate it with css transitions or animations.

The problem is that I would like it to stay expanded even after the mouse moves away. And I would like to do it without javascript.

Is that possible? Thanks!

like image 837
Jaska Avatar asked Apr 10 '12 14:04

Jaska


People also ask

How do you trigger transitions in CSS?

Triggering transitions You can trigger CSS transitions directly with pseudo classes like :hover (activates when the mouse goes over an element), :focus (activates when a user tabs onto an element, or when a user clicks into an input element), or :active (activates when user clicks on the element).

Which animation techniques appear when the users mouse hovers over the elements?

Hover animation is used to elevate or scale up a UI element when the user hovers on it.

How do you keep an animation in CSS?

The only way to truly pause an animation in CSS is to use the animation-play-state property with a paused value. In JavaScript, the property is “camelCased” as animationPlayState and set like this: element. style.


1 Answers

No it's not possible because every css that will be applied on mouseover ( :hover ) will be removed on mouseout and there is no other way to capture mouseover and out.

#animate:hover {
    /* ex. -webkit- -moz- -ms- -o-​ */ animation: animation 2s infinite; /* will be directly aborted on mouseout :( */
}

So you should use JavaScript for that.

like image 92
noob Avatar answered Sep 29 '22 20:09

noob