2

I have an animation on my site which goes from width: 100px to 800px when hover on.

But when hover out, it just goes to the normal position with no animation.

How could I get it so the animation would go back on hover-out the same way it came on hover?

I only found solutions for transitions, but I need it for animation.

<div id="blackbox"/>
<div id="blacktxt">
Navigation
</div>

See Here

4

2 回答 2

9

为什么不使用过渡而不是动画?工作的jsFiddle

#blackbox {
    background: black;
    width: 100px; 
    height: 80px; 
    color: white; 
    text-align: center; 
    font-family: Times; 
    font-size: 20px;
    position: fixed;
    left: 0px;
    bottom: 100px;
    opacity: 0.5;
    margin-bottom: 10px;
    transition: all 2s; /* Add this transition */
}


#blackbox:hover { /* Apply the new design on hover */
    opacity: 0.8;
    width: 800px;
}

#blacktxt {
    margin-top: 10px;
    height: 60px;
    transition: opacity 0.5s, width 5s;
    position: absolute;
    font-family: cursive;
    cursor: default;
}

#blacktxt:hover {
    opacity: 0;
}
于 2013-08-29T14:27:17.907 回答
0

我为此编写了jQuery Reversible插件。与 CSS 过渡相比,它的主要优势在于它适用于 IE9 和旧版浏览器。

于 2013-12-02T14:49:59.813 回答