我试图让我的 CSS 过渡顺利进行,但我遇到了最后一个问题。我承认这很肤浅,但如果可能的话,我想把它“修复”。我已经在 Chrome、Firefox 和 IE 中尝试过它,它在所有浏览器中都这样做。
我正在操作的UL
和LI
元素是导航工具栏的一部分。工具栏可以在以下 URL 的左上角看到:http:
//fretfast.com/templates/clean/sample.php
当您将鼠标悬停在具有可扩展列表的元素之一上时,例如learn
、teach
或community
,您会看到它非常平滑地展开(当然,假设您的浏览器支持 CSS3 过渡);但是,当您将鼠标从可扩展列表上移开时,列表顶部的边缘区域会立即消失,这会使所有后续文本上移过快。
例如,如果您将鼠标悬停在 上learn
,将显示一个可扩展菜单,其中提供lessons
、questions
和选项tips
。但是,当您将鼠标移出并且菜单折叠时,第一个选项 ( lessons
) 会立即向上推,使其位于按钮主要文本 ( learn
) 的正下方。
这是我用于导航栏的 CSS,但对于我的生活,我无法弄清楚为什么高度过渡只在一个方向上起作用。
#topNav {
list-style-type: none; height: 25px; padding: 0; margin: 0;
}
#topNav * { font-size: 15px; }
#topNav li {
float: left; position: relative; z-index: 1;
padding: 0; line-height: 23px; background: none; repeat-x 0 0;
padding-top: 2px;
}
#topNav li:hover {
background-color: #C0C0C0; z-index: 2;
padding-top: 0;
border-top: 2px solid #59B4FF;
}
#topNav li a {
display: block; padding: 0 15px; color: #000; text-decoration: none;
}
#topNav li a:hover { color: #222222; }
#topNav li ul {
opacity: 0; position: absolute; left: 0; width: 8em; background: #C0C0C0;
list-style-type: none; padding: 0; margin: 0;
}
#topNav li:hover ul { opacity: 1; }
#topNav li ul li {
float: none; position: static; height: 0; line-height: 0; background: none;
}
#topNav li:hover ul li {
height: 25px; line-height: 25px;
}
#topNav li ul li a { background: #C0C0C0; }
#topNav li ul li a:hover {
text-indent: 0.3em;
background-color: #59B4FF;
}
#topNav li {
transition: background-color 0.2s ease;
-o-transition: background-color 0.2s ease;
-moz-transition: background-color 0.2s ease;
-webkit-transition: background-color 0.2s ease;
}
#topNav li a {
transition: all 0.2s ease;
-o-transition: all 0.2s ease;
-moz-transition: all 0.2s ease;
-webkit-transition: all 0.2s ease;
}
#topNav li ul {
transition: all 0.3s ease;
-o-transition: all 0.3s ease;
-moz-transition: all 0.3s ease;
-webkit-transition: all 0.3s ease;
}
#topNav li ul li {
transition: height 0.5s ease;
-o-transition: height 0.5s ease;
-moz-transition: height 0.5s ease;
-webkit-transition: height 0.5s ease;
}
#topNav li ul li a {
transition: all 0.3s ease;
-o-transition: all 0.3s ease;
-moz-transition: all 0.3s ease;
-webkit-transition: all 0.3s ease;
transition: text-indent 0.1s linear;
-o-transition: text-indent 0.1s linear;
-moz-transition: text-indent 0.1s linear;
-webkit-transition: text-indent 0.1s linear;
}
我不相信这与两者中的padding-top
规范有任何关系#topNav li
,因为我今天刚刚添加了边框突出显示效果,而这个问题已经持续了更长的时间。任何帮助是极大的赞赏。