【问题标题】:css3 transition: different time value when :hover In than Out?css3 过渡:不同的时间值:hover In 而不是 Out?
【发布时间】:2012-01-15 01:00:50
【问题描述】:

基本上我试图在项目悬停时与鼠标离开时有不同的过渡时间,

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

【问题讨论】:

    标签: css css-transitions


    【解决方案1】:

    我建议这样做:

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

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

    这里的工作演示:http://jsfiddle.net/jfriend00/Hufxa/

    【讨论】:

    • 注意:我认为您的意思是在转换时间中使用“转换”而不是“转换”,因此我编辑了答案以表明这一点。
    猜你喜欢
    • 2012-02-15
    • 2020-06-18
    • 2014-04-10
    • 2013-05-14
    • 2018-09-25
    • 2023-03-08
    • 1970-01-01
    • 2012-10-19
    • 2013-05-08
    相关资源
    最近更新 更多