嗨,伙计们,我一直有麻烦让我的子菜单下拉与CSS工作。我试图添加一个平滑的过渡外观,但目前菜单甚至不显示当我悬停。我肯定是漏掉了一些小东西,但我似乎就是不知道问题出在哪里。下面是代码:
#main-navigation ul.folder-child{
opacity: 0;
visibility: hidden;
-moz-transition: height 0.3s ease-in-out;
-ms-transition: height 0.3s ease-in-out;
-o-transition: height 0.3s ease-in-out;
-webkit-transition: height 0.3s ease-in-out;
transition: height 0.3s ease-in-out;
}
#main-navigation li:hover ul.folder-child{
opacity: 1;
visibility: visible;
top: 50px;
}
我很感激任何人能提供的任何帮助。提前感谢!
你只定义了高度的过渡,没有为高度定义css规则。这是你的解决方案。
请注意:对于height属性的过渡,您需要在正常和悬停状态下定义高度。
ul.folder-child {
width: 180px;
height: 0;
overflow: hidden;
opacity: 0;
visibility: hidden;
position:absolute;
top: 100%;
left: 0;
transition: all 0.4s ease-in-out;
-o-transition: all 0.4s ease-in-out;
-webkit-transition: all 0.4s ease-in-out;
}
#main-navigation li:hover > ul.folder-child {
height: 100px;
opacity: 1;
visibility: visible;
}
查看http://jsfiddle.net/logiccanvas/vWDvy/480/
也许检查一下你的浏览器,IE不支持所有的CSS3功能
也许使用display: none和display: block来代替不透明度和可视性;
会更好。<ul>
<li>
<a href="#">Item #1</a>
<ul>
<li><a href="">Sub-Item #1</a></li>
<li><a href="">Sub-Item #2</a></li>
<li><a href="">Sub-Item #3</a></li>
</ul>
</li>
<li>
<a href="#">Item #2</a>
<ul>
<li><a href="">Sub-Item #4</a></li>
<li><a href="">Sub-Item #5</a></li>
<li><a href="">Sub-Item #6</a></li>
</ul>
</li>
<li>
<a href="#">Item #3</a>
<ul>
<li><a href="">Sub-Item #7</a></li>
<li><a href="">Sub-Item #8</a></li>
<li><a href="">Sub-Item #9</a></li>
</ul>
</li>
</ul>
ul > li {display: block; float: left; margin-right: 10px; position: relative; background: Red; padding: 0.5em; line-height: 1em}
ul ul {display: none; width: 150px; position:absolute; top: 2em; left: 0}
ul ul > li {float: none;}
ul > li:hover > ul,
ul > a:hover + ul {display: block}
http://jsfiddle.net/spliter/vWDvy/也在IE上工作!