2012-01-14 124 views
3

基本上我想有項目時比當產品鼠標懸停闊葉不同的過渡時間,css3 transition:不同的時間值的時候:懸停in out out?

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

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

而且像

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

這樣,它會採取0.2秒到被顯示和2秒隱藏

我可以做到這一點,不需要JavaScript?

回答

9

我建議這樣的:

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

而且,我們的CSS事物處理的順序爲你的時候:懸停生效(這將覆蓋其他)。

工作演示在這裏:http://jsfiddle.net/jfriend00/Hufxa/

+0

注:我覺得你的意思是使用「過渡」,而不是「改造」與你的過渡時間,所以我編輯我的回答表明。 – jfriend00 2012-01-14 16:50:44

+0

添加鏈接到工作演示。 – jfriend00 2012-01-14 17:01:08