1

我有一个包含过渡的布局,它们顺利进入该过渡,但一旦光标离开所选区域,它们就会突然回到第一个位置。

}
#holder div:hover {
    width:92px;
    background-color:#dddddd;
    -webkit-transition:all .4s ease-out;
    -moz-transition:all .4s ease-out;
    -ms-transition:all .4s ease-out;
    -o-transition:all .4s ease-out;
    transition:all .4s ease-out;

这就是它的编码,有没有人能帮我把它顺利恢复到原来的形式?谢谢!

4

1 回答 1

2

div此选择器仅在 a是其子级#holder时才匹配:hover

#holder div:hover {
    background-color: #DDD;
    -webkit-transition: all 0.4s ease-out;
    -moz-transition: all 0.4s ease-out;
    -ms-transition: all 0.4s ease-out;
    -o-transition: all 0.4s ease-out;
    transition: all 0.4s ease-out;
    width: 92px;
}

这意味着您的转换仅在 div 悬停时适用。停止悬停后,过渡不再适用,样式将跳回。

要让它双向工作,您需要将转换声明放在#holder div

#holder div {
    -webkit-transition: all 0.4s ease-out;
    -moz-transition: all 0.4s ease-out;
    -ms-transition: all 0.4s ease-out;
    -o-transition: all 0.4s ease-out;
    transition: all 0.4s ease-out;
}
#holder div:hover {
    background-color: #DDD;
    width: 92px;
}
于 2012-11-29T18:20:51.063 回答