Keeping style applied using :hover until transition complete?

≡放荡痞女 提交于 2019-12-05 07:01:45

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

This works in Firefox (8.0.1) and Webkit.

noob

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

Try using transitions like in http://jsfiddle.net/frozenkoi/YK52N/ (note the comments in the CSS section, for both the .item and .item:hover)

The trick is to use transitions for the z-index property too. You can set, for example, a value of 10 for the normal items and 11 for the hovered ones. You also have to use transition-delay so that the animation for moving the mouse out doesn't reset the z-index inmediately. Next, add a different value to transition-delay to the rule for :hover with a value of zero so that the z-index does update inmediately when the mouse goes into the item.

In short, .item has the transition for mouse out of the item and .item:hover the rules for when the mouse moves in.

Here's the one solution: http://jsfiddle.net/uHJwT/4/

Essentially, it uses another wrapper div that has sufficient width & height to cover animated surface - on hover, it elevates its z-index so that the animated div remains on top. Of course, this is not full-proof solution - it is based on the fact that typical hover off would be down movement and it works for that - but hover off in diagonal direction would not work. But seems to be a reasonable CSS only solution - I would rather used js to get a perfect one.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!