css3 transition: different time value when :hover In than Out?

时间秒杀一切 提交于 2019-12-10 17:37:24

问题


Basically i am trying to have different transition time when the item is hovered than when the item is mouse leaved,

#bar{ position:fixed; bottom:-25px; }  /*here you only get to see a piece of the bar    */

#bar:hover{ transform: .2s linear; bottom:0; }

And something like

/*this only represents my made out status to cover what i need*/
#bar:mouseLeaved{ transform: 2s linear }

This way it would take .2 seconds to be shown and 2 seconds to be hidden

Can i do this with no need of javascript?


回答1:


I'd suggest this:

#bar { transition: 2s linear; }
#bar:hover { transition: .2s linear; }

And, let the ordering of the CSS handle things for you when :hover is in effect (it will override the other).

Working demo here: http://jsfiddle.net/jfriend00/Hufxa/



来源:https://stackoverflow.com/questions/8863583/css3-transition-different-time-value-when-hover-in-than-out

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