Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keeping style applied using :hover until transition complete?

I have a bunch of tiles on a page that expand as the user mouses over them. The expanded one should have the highest z-index, and this works, but I need the z-index to remain until the size transition is complete. Is there a way to do this using CSS only, no JavaScript? Since I'm using transitions, I'm not too worried about compatibility here, I applied progressive enhancement correctly.

Here's a jsFiddle that demonstrates this. Mouse over A; it transitions out. Mouse off of it, however, and it falls behind B. I need it to stay in front of B until the transition completes. Is there an elegant way to do this?

like image 326
Ry- Avatar asked Nov 25 '11 04:11

Ry-


2 Answers

You need to define the z-index, as well as animate it.

This works in Firefox (8.0.1) and Webkit.

like image 199
bookcasey Avatar answered Sep 28 '22 11:09

bookcasey


You need to set z-index to transition too: http://jsfiddle.net/uHJwT/2/

like image 25
noob Avatar answered Sep 28 '22 09:09

noob