【发布时间】:2013-05-11 04:49:29
【问题描述】:
我有一个标准的嵌套 UL 导航结构和一些 CSS 来为 :hover 上的子导航设置动画...
看到这个小提琴:http://jsfiddle.net/5kwsV/
一切都按预期工作,除了最深 UL 上的动画。第一个子导航动画高度,第二个应该只动画宽度。
这是处理我遇到问题的最深 UL 动画的代码。
nav ul li > ul > li > ul {
position: absolute;
display: block;
visibility: hidden;
width: 0px;
height: auto;
top: 0;
left: 100px;
padding: 0;
margin: 0;
-webkit-transition: all 0.6s ease;
-moz-transition: all 0.6s ease;
-ms-transition: all 0.6s ease;
-o-transition: all 0.6s ease;
transition: all 0.6s ease;
}
nav ul li > ul > li:hover > ul {
position: absolute;
display: block;
visibility: visible;
width: 100px;
height: auto;
top: 0;
left: 100px;
padding: 0;
margin: 0;
-webkit-transition: all 0.6s ease;
-moz-transition: all 0.6s ease;
-ms-transition: all 0.6s ease;
-o-transition: all 0.6s ease;
transition: all 0.6s ease;
}
现在,上面代码的问题在于,当将鼠标悬停在“Michael”导航标签上时,宽度和高度会产生动画。它只需要为宽度设置动画。看起来解决方案很明显,将“all”更改为“width”。
我改这个...
-webkit-transition: all 0.6s ease;
-moz-transition: all 0.6s ease;
-ms-transition: all 0.6s ease;
-o-transition: all 0.6s ease;
transition: all 0.6s ease;
到这里……
-webkit-transition: width 0.6s ease;
-moz-transition: width 0.6s ease;
-ms-transition: width 0.6s ease;
-o-transition: width 0.6s ease;
transition: width 0.6s ease;
现在,当悬停时,动画的动画宽度应该是 0 到 100 像素。新问题是当我移动到不同的导航标签时,它应该从 100px 动画回到 0px,但它只是在那里闪烁。
我错过了什么?我这辈子都看不到它,我敢肯定它是显而易见的!
【问题讨论】:
标签: html css animation css-transitions