css3 过渡 : different time value when :hover In than Out?

标签 css css-transitions

基本上我试图在元素悬停时和鼠标离开时有不同的过渡时间,

#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 的情况下做到这一点吗?

最佳答案

我建议这样做:

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

并且,当 :hover 生效时,让 CSS 的顺序为您处理事情(它将覆盖另一个)。

此处的工作演示:http://jsfiddle.net/jfriend00/Hufxa/

关于css3 过渡 : different time value when :hover In than Out?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8863583/

相关文章:

javascript - 调整 div 的高度 - 基于分辨率和元素数

css - 当页面使用灰色背景图像时,组合框出现在 IE6 中

jquery - CSS 过渡初始状态错误

javascript - 使用 CSS Transitions 从同一方向将内容过渡到 View 中

html - 无法在 Firefox/IE 中将我的背景居中 - 无法在背景 HTML 上显示菜单

没有切割段落的css3列

css - 仅使用 CSS3 更改其子元素悬停时的元素样式

当鼠标悬停在同级子元素的另一个元素上时,CSS div 会淡出

html - CSS3 过渡在流体宽度设计中创建间隙和重叠

jquery - 查找具有特定类别的列表中的所有链接